Thread: why i get this errors..

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    why i get this errors..

    1>c:\documents and settings \my documents\visual studio 2005\projects\ex6\ex6\ex6.c(14) : error C2143: syntax error : missing ';' before 'type'
    1>c:\documents and settings\ my documents\visual studio 2005\projects\ex6\ex6\ex6.c(15) : error C2143: syntax error : missing ';' before 'type'
    1>c:\documents and settings\ my documents\visual studio 2005\projects\ex6\ex6\ex6.c(16) : error C2143: syntax error : missing ';' before 'type'
    1>c:\documents and settings\ my documents\visual studio 2005\projects\ex6\ex6\ex6.c(17) : error C2065: 'a' : undeclared identifier
    1>c:\documents and settings\ my documents\visual studio 2005\projects\ex6\ex6\ex6.c(17) : error C2065: 'b' : undeclared identifier
    1>c:\documents and settings\ my documents\visual studio 2005\projects\ex6\ex6\ex6.c(17) : error C2065: 'c' : undeclared identifier

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #define false 0
    #define true 1
    
     
      
    int main()
    {
    
    	FILE *f;
    	f=fopen("c:\\ware1.txt","r");
    	char a[20];
    	char b[20];
    	char c[20];
    	fscanf(f,"%20[^ ]%20[^ ]%20[^ ]%*c",a,b,c);
    	fclose(f);
    	return 0;
    }

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    You have to provide a data type in here:

    %20[^ ]

  3. #3
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    still i get the same errors
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #define false 0
    #define true 1
    
     
      
    int main()
    {
    
    	FILE *f;
    	f=fopen("c:\\ware1.txt","r");
    	char a[20];
    	char b[20];
    	char c[20];
    	fscanf(f,"%20[^ ]c%20[^ ]c%20[^ ]c%*c",a,b,c);
    	fclose(f);
    	return 0;
    }

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I don't know if it's legal to put nothing after the circumflex ^.

    I assume you want it to avoid whitespace blanks or what?

  5. #5
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    the first line in the file is
    W1 44444 WingThing 20
    so i need to have
    a=W1
    b=44444
    c=WingThing
    why idont have that
    i told it to stop on space char
    ??
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #define false 0
    #define true 1
    
     
      
    int main()
    {
    
    	FILE *f;
    	
    	char a[20];
    	char b[20];
    	char c[20];
    	f=fopen("c:\\ware1.txt","r");
    	fscanf(f,"%20[^ ]%20[^ ]%20[^ ]%*c",a,b,c);
    	fclose(f);
    	return 0;
    }

  6. #6
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    ok this works
    but i am sure if it ignores one char at the end or justthe rest chars
    i dont wont to stack the buffer with garbage
    ??
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #define false 0
    #define true 1
    
     
      
    int main()
    {
    
    	FILE *f;
    	
    	char a[20];
    	char b[20];
    	char c[20];
    	f=fopen("c:\\ware1.txt","r");
    	fscanf(f,"%20s%20s%20s%*c",a,b,c);
    	fclose(f);
    	return 0;
    }

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Just use fscanf() to take in the W1, as a string. It will automatically stop at the first space it comes to.

    Then use another %s for your next bit, etc.

  8. #8
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    but i am sure if it ignores one char at the end or justthe rest chars
    i dont wont to stack the buffer with garbage
    ??

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I wouldn't do the "ignore" thing. Take in what you want, and then handle it in the buffer for any particulars. Don't ask too much from fscanf() - it's liable to fail and leave your program mangled.

  10. #10
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    does fscanf self progessing on the file?

  11. #11
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Yes, it moves the file pointer as it scans, if that's what you are asking.

  12. #12
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  2. Winsock compilation errors
    By jmd15 in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-03-2005, 08:00 AM
  3. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  4. Help me with these errors... :-(
    By major_small in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2003, 08:18 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM