Hey all I'm struggling with my project to extract occurrences of a word from a text file. The semantics of opening/using the file are giving me massive headaches, but first off I'd really like just to be able check a given letter for being part of a word.
It seems like an easy task in C, just using isAlpha(), but the same thing doesn't seem to work in C++. What's the #include file for a similar function?
My code is:
bool isNotWhitespace(char c){
return ((isaplha(c) != 0) || c == "-" || c == "'");
but that gives me a whole host of errors, mostly about conversion from char* to int. The documentation didn't seem to mention it, and it's not even a char*?!!
Use single quotes ( ' ) to refer to the value of a single character. E.g. 'A'==65
Use double quotes ( " ) to refer to a pointer to static char array. E.g. sizeof("A")==sizeof(char *)
By the way, the only whitespace characters in ASCII are 0x09, 0x0A, 0x0B, 0x0C, 0x0D, and 0x20. If we include ISO-8859-1, the list also includes 0x85 and 0xA0.
hey thats awesome!! its good finding these little tricks.
However in the spec I've got ' counts as a letter so I need to check for that. However when I write that, it's just three apostrophes (''') so makes the rest of my code into a quote?