Click here to Skip to main content
16,011,805 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Number of characters of a string Pin
wira1guys17-Dec-07 21:20
wira1guys17-Dec-07 21:20 
QuestionRe: Number of characters of a string Pin
CPallini17-Dec-07 22:02
mveCPallini17-Dec-07 22:02 
GeneralRe: Number of characters of a string Pin
CodingLover17-Dec-07 22:35
CodingLover17-Dec-07 22:35 
GeneralRe: Number of characters of a string Pin
Maxwell Chen17-Dec-07 22:36
Maxwell Chen17-Dec-07 22:36 
GeneralRe: Number of characters of a string Pin
CodingLover17-Dec-07 23:01
CodingLover17-Dec-07 23:01 
JokeRe: Number of characters of a string Pin
CPallini17-Dec-07 23:12
mveCPallini17-Dec-07 23:12 
GeneralRe: Number of characters of a string Pin
CodingLover17-Dec-07 23:31
CodingLover17-Dec-07 23:31 
GeneralRe: Number of characters of a string Pin
cp987617-Dec-07 23:37
cp987617-Dec-07 23:37 
This is nonsense! There is nothing wrong with testing

if (c == '\n') {}

some folk suggest that you write:

if ('\n' == c) {}

as this results in an error if you type '=' instead of '==' but I find this hard to read so I use the first form. Most compilers will issue a warning for assignment in comparison operations these days.

I mentioned the isspace() function as when I see people testing for the whitespace characters it looks as if they don't know about it. It is much more efficient. If it is not what you need and you have to test for multiple characters, it is much more efficient to do:

switch (c)<br />
{<br />
   case '\n':<br />
   case '\r':<br />
   case '\t':<br />
   case ' ':<br />
..<br />
   break;<br />
...<br />
}

Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

GeneralRe: Number of characters of a string Pin
CPallini18-Dec-07 0:04
mveCPallini18-Dec-07 0:04 
GeneralRe: Number of characters of a string Pin
cp987618-Dec-07 0:15
cp987618-Dec-07 0:15 
GeneralRe: Number of characters of a string Pin
CPallini18-Dec-07 0:43
mveCPallini18-Dec-07 0:43 
GeneralRe: Number of characters of a string Pin
cp987618-Dec-07 10:07
cp987618-Dec-07 10:07 
GeneralYou're right Pin
CPallini18-Dec-07 12:33
mveCPallini18-Dec-07 12:33 
GeneralRe: Number of characters of a string Pin
CodingLover18-Dec-07 0:18
CodingLover18-Dec-07 0:18 
GeneralRe: Number of characters of a string Pin
Maxwell Chen18-Dec-07 1:16
Maxwell Chen18-Dec-07 1:16 
QuestionRe: Number of characters of a string Pin
David Crow18-Dec-07 3:20
David Crow18-Dec-07 3:20 
GeneralRe: Number of characters of a string Pin
David Crow18-Dec-07 3:30
David Crow18-Dec-07 3:30 
GeneralRe: Number of characters of a string Pin
jhwurmbach18-Dec-07 4:05
jhwurmbach18-Dec-07 4:05 
GeneralRe: Number of characters of a string Pin
David Crow18-Dec-07 4:14
David Crow18-Dec-07 4:14 
GeneralRe: Number of characters of a string Pin
jhwurmbach18-Dec-07 4:29
jhwurmbach18-Dec-07 4:29 
QuestionHow to read only the integer value of a txt file in C++ Pin
Cabomba17-Dec-07 20:20
Cabomba17-Dec-07 20:20 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Peter Weyzen17-Dec-07 20:48
Peter Weyzen17-Dec-07 20:48 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Cabomba17-Dec-07 21:36
Cabomba17-Dec-07 21:36 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Iain Clarke, Warrior Programmer17-Dec-07 23:48
Iain Clarke, Warrior Programmer17-Dec-07 23:48 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Cabomba18-Dec-07 19:50
Cabomba18-Dec-07 19:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.