+ 3

Read wstring using File pointer

Hi I have used _wfopen in a+ mode. I am able to use fwscanf to read content of file but it gets terminated when there is white space. Is there a way to read full line till new line character is occured ? Also need to know where file pointer is reached by reading a single line. Many thanks in advance..

2nd Sep 2021, 3:34 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
5 Respuestas
+ 3
Ketan Lalcheta I have minimal experience with wide strings in file handling, so I am shooting in the dark now. It might work without the "ls", so try "%[^\n]" exactly. BTW, it is recommended to use fgetws() instead of fwscanf().
2nd Sep 2021, 4:05 PM
Brian
Brian - avatar
+ 3
Have you tried the format "%[^\n]"? The C function ftell() can report the current byte offset in the file stream.
2nd Sep 2021, 3:50 PM
Brian
Brian - avatar
+ 3
Ipang i have not attach it here as this is piece of code from main project Also does file reading work on sololearn? If yes, I can share code here.
2nd Sep 2021, 3:55 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
Brian it is wide string so I had %ls.... I changed to %[^\n]ls And %s[^\r\n]ls None of them worked... Am I missing something ?
2nd Sep 2021, 3:57 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
Thanks Brian ...I have chosen fgetws().
3rd Sep 2021, 7:24 AM
Ketan Lalcheta
Ketan Lalcheta - avatar