| |

VerySource

 Forgot password?
 Register
Search
Author: onethen123

Please help me reading files

[Copy link]

0

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 United States

Post time: 2020-12-11 14:00:01
| Show all posts
Reading character by character is too slow
You can allocate a large enough string, such as 1024 bytes, use the fgets function to read one line of content at a time, and then use the strchr or strstr function to intercept the content one by one according to the separator, and then loop

char szBuffer[1024];
while(!fgets(szBuffer, fp)) {
  if (strchr(szBuffer,'#')) {
  }
  if (strchr(szBuffer,'*')) {
  }
  if (strchr(szBuffer, '&')) {
  }
  if (strchr(szBuffer,'$')) {
  }
  if (strchr(szBuffer,'!')) {
  }
}
Reply

Use magic Report

2

Threads

10

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-12-11 14:15:01
| Show all posts
Thanks, I will try it right away.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list