How do I check if the line is over?

Dominykas Ber

I ran into a problem today. I can't find a way to check if a line in a file is over and the words are read from the next one already. I read word by word from the file using fscanf, then process the word as I need to and print it out into another file but there is a problem.

for example my data file is:

Hello, how are you
doing?

and the result file shows:

Hello, how are you doing?

but i need the words to be in the same lines from which I took them. Please keep in mind that I need those words one by one, that is why I don't use getline()

here is my code of how I read words from the file:

while( fscanf(file, "%s", A) != EOF )
        {
            check(A, B, &a); // I edit the words and put them in B string
                             // which is printed to the write file
        }

Thank you for any tips!

Barmar

Read the line into a string with getline() or fgets(), then use sscanf to get the words out of this string.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How do I put text over the picture?

분류에서Dev

How do I check which key is pressed?

분류에서Dev

How do I check if Metadata exists with ServerManager?

분류에서Dev

How do I check if a variable exists in an 'if' statement?

분류에서Dev

how do I check coreutils version?

분류에서Dev

How do I check if an ID is a number?

분류에서Dev

How do I draw a line on a Lazarus form?

분류에서Dev

How do I display the whole line of text?

분류에서Dev

How do I loop over output from shuf?

분류에서Dev

How do I iterate over a Mac Resource Fork

분류에서Dev

How do I unit test a function that loops over objects?

분류에서Dev

How do I make a gif with text over frames

분류에서Dev

How do I check whether I am using LVM?

분류에서Dev

How do I check that a configuration file has been read?

분류에서Dev

How do I check if all elements of DataFrame are non-negative?

분류에서Dev

In protractor, how do I check if a table cell contains particular text?

분류에서Dev

How do I check if System::Collections::ArrayList exists / is empty

분류에서Dev

How do I check if a TDateEdit is left blank by the user?

분류에서Dev

How do I check if the current key is in my dictionary?

분류에서Dev

How do I check if git branch has a tracking branch?

분류에서Dev

How do I check CanCan abilities on an object in a `shared/partial`?

분류에서Dev

How do I check whether the enclosure failed or the hard drive failed?

분류에서Dev

How do I check to see if a word contains a letter or group of letters?

분류에서Dev

How do I check for a variable to be equal to multiple other variables?

분류에서Dev

How do I check if my OpenPGP key is in the Ubuntu keyserver?

분류에서Dev

How do I check virtualbox version from CLI

분류에서Dev

How do I check my version of GNOME-Shell?

분류에서Dev

How do I check the current boot parameter list in Linux?

분류에서Dev

How do I boot to a command line interface instead of a GUI?

Related 관련 기사

  1. 1

    How do I put text over the picture?

  2. 2

    How do I check which key is pressed?

  3. 3

    How do I check if Metadata exists with ServerManager?

  4. 4

    How do I check if a variable exists in an 'if' statement?

  5. 5

    how do I check coreutils version?

  6. 6

    How do I check if an ID is a number?

  7. 7

    How do I draw a line on a Lazarus form?

  8. 8

    How do I display the whole line of text?

  9. 9

    How do I loop over output from shuf?

  10. 10

    How do I iterate over a Mac Resource Fork

  11. 11

    How do I unit test a function that loops over objects?

  12. 12

    How do I make a gif with text over frames

  13. 13

    How do I check whether I am using LVM?

  14. 14

    How do I check that a configuration file has been read?

  15. 15

    How do I check if all elements of DataFrame are non-negative?

  16. 16

    In protractor, how do I check if a table cell contains particular text?

  17. 17

    How do I check if System::Collections::ArrayList exists / is empty

  18. 18

    How do I check if a TDateEdit is left blank by the user?

  19. 19

    How do I check if the current key is in my dictionary?

  20. 20

    How do I check if git branch has a tracking branch?

  21. 21

    How do I check CanCan abilities on an object in a `shared/partial`?

  22. 22

    How do I check whether the enclosure failed or the hard drive failed?

  23. 23

    How do I check to see if a word contains a letter or group of letters?

  24. 24

    How do I check for a variable to be equal to multiple other variables?

  25. 25

    How do I check if my OpenPGP key is in the Ubuntu keyserver?

  26. 26

    How do I check virtualbox version from CLI

  27. 27

    How do I check my version of GNOME-Shell?

  28. 28

    How do I check the current boot parameter list in Linux?

  29. 29

    How do I boot to a command line interface instead of a GUI?

뜨겁다태그

보관