How are cctype header functions accessible? [duplicate]Why does omission of “#include <string>” only sometimes cause compilation failures?Why it seems not necessary to include some STL headersHow do you set, clear, and toggle a single bit?How do I iterate over the words of a string?Why have header files and .cpp files?Can templates only be implemented in header files?Why do we need virtual functions in C++?In Node.js, how do I “include” functions from my other files?How to fix “Headers already sent” error in PHPNamespaces and the Pre-ProcessorWhy use namespace if iostream is importedError: Identifier “cout” is undefined. <iostream> included and using namespace std;

Papers on arXiv solving the same problem at the same time

Why is a statement like 1 + n *= 3 allowed in Ruby?

How were medieval castles built in swamps or marshes without draining them?

Redacting URLs as an email-phishing preventative?

Cost of oil sanctions to world's consumers

What is Spectral Subtraction for noise reduction?

Does the aliasing loophole apply to signed characters?

If the Shillelagh cantrip is applied to a club with non-standard damage dice, what is the resulting damage dice?

Do clerics commit a sin if they do not recite the liturgy of the hours?

Why error propagation in CBC mode encryption affect two blocks?

Why does a sticker slowly peel off, but if it is pulled quickly it tears?

How would a low-tech device be able to alert its user?

Unlock your Lock

I don't have the theoretical background in my PhD topic. I can't justify getting the degree

What happened to the HDEV ISS Experiment? Is it over?

How long do you think advanced cybernetic implants would plausibly last?

How many birds in the bush?

Hangman game in Python - need feedback on the quality of code

How can I download a file from a host I can only SSH to through another host?

Why is "-ber" the suffix of the last four months of the year?

Can Orcus use Multiattack with any melee weapon?

How do you capitalize agile costs with less mature teams?

How to prevent a hosting company from accessing a VM's encryption keys?

What's special ammo?



How are cctype header functions accessible? [duplicate]


Why does omission of “#include <string>” only sometimes cause compilation failures?Why it seems not necessary to include some STL headersHow do you set, clear, and toggle a single bit?How do I iterate over the words of a string?Why have header files and .cpp files?Can templates only be implemented in header files?Why do we need virtual functions in C++?In Node.js, how do I “include” functions from my other files?How to fix “Headers already sent” error in PHPNamespaces and the Pre-ProcessorWhy use namespace if iostream is importedError: Identifier “cout” is undefined. <iostream> included and using namespace std;






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0
















This question already has an answer here:



  • Why it seems not necessary to include some STL headers

    2 answers



  • Why does omission of “#include <string>” only sometimes cause compilation failures?

    6 answers



Character related functions are defined in the cctype header. I made a program which uses the ispunct() function defined in this header. Program is as follows:



#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main()
string s("Hello world!!!");
decltype(s.size()) punct_cnt = 0;

for(auto c : s)
if(ispunct(c))
punct_cnt++;



cout << "The string contains " << punct_cnt << " punctuation marks" << endl;

return 0;



Output is trivial. However, the program works totally fine even if I omit the cctype header include directive. How is the ispunct() function still accessible?










share|improve this question














marked as duplicate by NathanOliver c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 27 at 19:52


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    It works because <cctype> gets included indirectly. Don't count on such behavior. If you are going to use a function from <cctype>, include it.

    – R Sahu
    Mar 27 at 19:50











  • Ok but from where is it included indirectly? @RSahu

    – Navjot Singh
    Mar 27 at 19:51











  • iostream will most likely include cctype

    – NathanOliver
    Mar 27 at 19:52







  • 1





    Ok. So using a seperate include for cctype would be considered as a best practice?

    – Navjot Singh
    Mar 27 at 19:54






  • 2





    Yes. Always include what you need. It makes the code portable.

    – NathanOliver
    Mar 27 at 19:55

















0
















This question already has an answer here:



  • Why it seems not necessary to include some STL headers

    2 answers



  • Why does omission of “#include <string>” only sometimes cause compilation failures?

    6 answers



Character related functions are defined in the cctype header. I made a program which uses the ispunct() function defined in this header. Program is as follows:



#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main()
string s("Hello world!!!");
decltype(s.size()) punct_cnt = 0;

for(auto c : s)
if(ispunct(c))
punct_cnt++;



cout << "The string contains " << punct_cnt << " punctuation marks" << endl;

return 0;



Output is trivial. However, the program works totally fine even if I omit the cctype header include directive. How is the ispunct() function still accessible?










share|improve this question














marked as duplicate by NathanOliver c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 27 at 19:52


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    It works because <cctype> gets included indirectly. Don't count on such behavior. If you are going to use a function from <cctype>, include it.

    – R Sahu
    Mar 27 at 19:50











  • Ok but from where is it included indirectly? @RSahu

    – Navjot Singh
    Mar 27 at 19:51











  • iostream will most likely include cctype

    – NathanOliver
    Mar 27 at 19:52







  • 1





    Ok. So using a seperate include for cctype would be considered as a best practice?

    – Navjot Singh
    Mar 27 at 19:54






  • 2





    Yes. Always include what you need. It makes the code portable.

    – NathanOliver
    Mar 27 at 19:55













0












0








0









This question already has an answer here:



  • Why it seems not necessary to include some STL headers

    2 answers



  • Why does omission of “#include <string>” only sometimes cause compilation failures?

    6 answers



Character related functions are defined in the cctype header. I made a program which uses the ispunct() function defined in this header. Program is as follows:



#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main()
string s("Hello world!!!");
decltype(s.size()) punct_cnt = 0;

for(auto c : s)
if(ispunct(c))
punct_cnt++;



cout << "The string contains " << punct_cnt << " punctuation marks" << endl;

return 0;



Output is trivial. However, the program works totally fine even if I omit the cctype header include directive. How is the ispunct() function still accessible?










share|improve this question















This question already has an answer here:



  • Why it seems not necessary to include some STL headers

    2 answers



  • Why does omission of “#include <string>” only sometimes cause compilation failures?

    6 answers



Character related functions are defined in the cctype header. I made a program which uses the ispunct() function defined in this header. Program is as follows:



#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main()
string s("Hello world!!!");
decltype(s.size()) punct_cnt = 0;

for(auto c : s)
if(ispunct(c))
punct_cnt++;



cout << "The string contains " << punct_cnt << " punctuation marks" << endl;

return 0;



Output is trivial. However, the program works totally fine even if I omit the cctype header include directive. How is the ispunct() function still accessible?





This question already has an answer here:



  • Why it seems not necessary to include some STL headers

    2 answers



  • Why does omission of “#include <string>” only sometimes cause compilation failures?

    6 answers







c++ header header-files






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 19:48









Navjot SinghNavjot Singh

21111 bronze badges




21111 bronze badges





marked as duplicate by NathanOliver c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 27 at 19:52


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











marked as duplicate by NathanOliver c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 27 at 19:52


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by NathanOliver c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 27 at 19:52


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 2





    It works because <cctype> gets included indirectly. Don't count on such behavior. If you are going to use a function from <cctype>, include it.

    – R Sahu
    Mar 27 at 19:50











  • Ok but from where is it included indirectly? @RSahu

    – Navjot Singh
    Mar 27 at 19:51











  • iostream will most likely include cctype

    – NathanOliver
    Mar 27 at 19:52







  • 1





    Ok. So using a seperate include for cctype would be considered as a best practice?

    – Navjot Singh
    Mar 27 at 19:54






  • 2





    Yes. Always include what you need. It makes the code portable.

    – NathanOliver
    Mar 27 at 19:55












  • 2





    It works because <cctype> gets included indirectly. Don't count on such behavior. If you are going to use a function from <cctype>, include it.

    – R Sahu
    Mar 27 at 19:50











  • Ok but from where is it included indirectly? @RSahu

    – Navjot Singh
    Mar 27 at 19:51











  • iostream will most likely include cctype

    – NathanOliver
    Mar 27 at 19:52







  • 1





    Ok. So using a seperate include for cctype would be considered as a best practice?

    – Navjot Singh
    Mar 27 at 19:54






  • 2





    Yes. Always include what you need. It makes the code portable.

    – NathanOliver
    Mar 27 at 19:55







2




2





It works because <cctype> gets included indirectly. Don't count on such behavior. If you are going to use a function from <cctype>, include it.

– R Sahu
Mar 27 at 19:50





It works because <cctype> gets included indirectly. Don't count on such behavior. If you are going to use a function from <cctype>, include it.

– R Sahu
Mar 27 at 19:50













Ok but from where is it included indirectly? @RSahu

– Navjot Singh
Mar 27 at 19:51





Ok but from where is it included indirectly? @RSahu

– Navjot Singh
Mar 27 at 19:51













iostream will most likely include cctype

– NathanOliver
Mar 27 at 19:52






iostream will most likely include cctype

– NathanOliver
Mar 27 at 19:52





1




1





Ok. So using a seperate include for cctype would be considered as a best practice?

– Navjot Singh
Mar 27 at 19:54





Ok. So using a seperate include for cctype would be considered as a best practice?

– Navjot Singh
Mar 27 at 19:54




2




2





Yes. Always include what you need. It makes the code portable.

– NathanOliver
Mar 27 at 19:55





Yes. Always include what you need. It makes the code portable.

– NathanOliver
Mar 27 at 19:55












0






active

oldest

votes














0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.





Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript