5

hey everyone, i am in desperate need with something soooo simple!!!

view full story
linux-howto

http://www.daniweb.com – Hey everyone, I have a simple simple problem that is literally driving me insane. Basically, I have a database of numbers seperated my spaces. I just took a segment of my code because I am soooo completely lost with the output!! If the database is: 1 2 3 9 7 6 4 5 6 7 I don't understand why my output is 1 for every single line??? How is the sscanf statement not taking the next string?? Someone please help I am desperate!! #include <stdio.h> main() {                 char buffer[20000];         char pid_temp[501], arrival_time_temp[501], CPU_burst_temp[501], IO_burst_temp[501];                FILE *fp;                 fp = fopen("CPULoad.dat", "r");         fgets(buffer, 20000, fp);                        fp = fopen("CPULoad.dat", "r");         fgets(buffer, 20000, fp);                 sscanf(buffer, "%s", CPU_burst_temp);         printf("%s\n", CPU_burst_temp);         sscanf(buffer, "%s", CPU_burst_temp);         printf("%s\n", CPU_burst_temp);         sscanf(buffer, "%s", CPU_burst_temp);         printf("%s\n", CPU_burst_temp);         sscanf(buffer, "%s", CPU_burst_temp);         printf("%s\n", CPU_burst_temp);         sscanf(buffer, "%s", CPU_burst_temp);         printf("%s\n", CPU_burst_temp);         sscanf(buffer, "%s", CPU_burst_temp);         printf("%s\n", CPU_burst_temp);         sscanf(buffer, "%s", CPU_burst_temp);         printf("%s\n", CPU_burst_temp);                 close(fp); } (General)