开发者

writing a single line of a file in C++ into two different arrays

suppose a text file has 11001100 11001101

and i open the text file and take the input from the file as pt[0]=11001100, pt[1]=11001101..

but if i take the input from file as in>>pt it wont put it in two different arrays which is obvious but it takes the whole line . Thus I have to take another for loop and traverse through the whole string and when I find a null character i start put开发者_Python百科ting into the second array . But how can I do it without putting it into a variable and traversing .. I mean directly from the file itself ..


Read it one byte at a time (e.g. with fread()). Append each byte to pt[i], where i is incremented when a space is encountered.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜