Tuesday 15 February 2011

c++ - how to check for '\t'? -



c++ - how to check for '\t'? -

i have code reads in text file, , turns each word file character array (needs character array, no strings allowed) that's info fellow member of word class. when punctuation encountered, word objects stored sentence class linked list. when tab encountered, sentences before stored in paragraph class linked list. need help way check '\t' in text file. i'm reading in using

while(myfile >> chararray){ //stuff }

as reads in total word , stores in chararray. if end of sentence, chararray[size] (size beingness lastly element) == '.' || == "!" || == "?" can handle making new sentence every time (i can assume text file formatted every time). don't know how how check '\t' character create new paragraph. '\t' picked myfile >> chararray? tried messing around various if statements see if pick '\t' character haven't been able to. how can check tab while reading in text file character array?

iostreams operator>> will, default, read , discard leading whitespace. including tab character begins new paragraph. suggest blank line should considered paragraph separator. , many people utilize run of normal space characters @ origin of line produce indentation, instead of tab, should check too.

my preferred approach utilize getline read entire line of text, whitespace , all. test first character , decide whether start new paragraph. load line stringstream , utilize operator>> pull out individual words. pretty similar r sahu's comment... not split line on tab characters. rather, you're concerned tabs/spaces @ origin of line only.

you can experiment noskipws , reading individual whitespace characters

c++ arrays ifstream character-arrays

No comments:

Post a Comment