0

this is the file

0   4fd4074a    12  1   1a740   3   2   @BOק15  
1   4fd4074a    12  1   1873c   3   2   @BN15  
2   4fd4074a    12  1   276b6   3   2   @BOק0120  
3   4fd4074a    12  1   5de0    3   2   @BOק15  
4   4fd4074a    12  1   24115   3   2   @BOק0120  
5   4fd4074a    12  1   1ff079  3   2   @BOק0120  
6   4fd40750    12  1   24115   3   2   @BN0120  
7   4fd40751    12  1   ec54    3   2   @BN15 

how to read it using sscanf?

    Temp = getLineByHandle(fileHandler);
    // ----
    char var1[1024] = {0};
    char var2[1024] = {0};
    char var3[1024] = {0};
    char var4[1024] = {0};
    char var5[1024] = {0};
    char var6[1024] = {0};
    char var7[1024] = {0};
    char var8[1024] = {0};
    // ----
    sscanf(Temp, "%s/t%s/t%s/t%s/t%s/t%s/t%s/t%s", var1, var2, var3, var4, var5, var6, var7, var8);
    // ----
    printf("%s\s",var2);
    getchar();

my code don't working

i tryed like this too already

sscanf(Temp, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s"

so how can i format such type of format

last variable in the table is string (message) like this (hello wsup ???") each space between vars is (0x09) that mean tab

(link to full code http://pastebin.com/d7yvMVJr)

Dinoel Vokiniv
  • 183
  • 3
  • 14

1 Answers1

0

If you're going to treat all fields as strings, you don't need to specify the tab character in the format specifier string. The *scanf family of functions ignores whitespaces by default. Additionally, check the return type of sscanf to make sure all eight items have been read.

dirkgently
  • 108,024
  • 16
  • 131
  • 187
  • `fgets` reads until a newline or EOF is reached. Is that what you want? `fgets` can be useful to get a line at a time from the console. However, parsing that string still needs to be done and you will require something akin to `sscanf`. However, there are others like `strtok` (unsafe) and `strcspn` which you can use to tokenize your input. The last-ditch effort would be to iterate over each character and tokenize the string yourself. – dirkgently Jun 11 '12 at 18:05