CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Jan 2009
    Posts
    156

    why i get these 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
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: why i get these errors..

    I only get warnings about deprecated functions in VS2005... which compiler are you using?
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: why i get these errors..

    Me too.

  4. #4
    Join Date
    Jan 2009
    Posts
    156

    Re: why i get these errors..

    visual studio 2005

  5. #5
    Join Date
    Jan 2009
    Posts
    156

    Re: why i get these errors..

    in the end i write &#37;*c

    so it ignores of 1 char or the rest?

  6. #6
    Join Date
    Nov 2006
    Location
    Essen, Germany
    Posts
    1,344

    Re: why i get these errors..

    string.h is deprecated and superceded by cstring

    Furthermore the keywords true and false are reserved keywords in C++, so don&#180;t #define them.
    - Guido

  7. #7
    Join Date
    Jan 2009
    Posts
    156

    Re: why i get these errors..

    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,"&#37;20[^ ]%20[^ ]%20[^ ]%*c",a,b,c);
    	fclose(f);
    	return 0;
    }

  8. #8
    Join Date
    Jan 2009
    Posts
    156

    Re: why i get these errors..

    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,"&#37;20s%20s%20s%*c",a,b,c);
    	fclose(f);
    	return 0;
    }

  9. #9
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: why i get these errors..

    Those original errors *could* have been caused if you were writing C rather than C++. In C you can't declare variables after making a statement, only at the very top of a block.

  10. #10
    Join Date
    Feb 2009
    Location
    Ukraine
    Posts
    64

    Re: why i get these errors..

    I suppose scanf format string is not intended to be used as a regular expression, while in your example you do mix original format string specifiers with regexp literals. Are you sure "[^ ]" would work aas expected? Excuse me if I'm offtop, but please clarify my assumption. Probably I'm missing something, or that is good VS2005 extension?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured