简体   繁体   中英

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 putting 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 (eg with fread()). Append each byte to pt[i], where i is incremented when a space is encountered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM