-
March 26th, 2009, 09:09 AM
#1
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;
}
-
March 26th, 2009, 09:22 AM
#2
Re: why i get these errors..
I only get warnings about deprecated functions in VS2005... which compiler are you using?
-
March 26th, 2009, 09:26 AM
#3
Re: why i get these errors..
-
March 26th, 2009, 09:30 AM
#4
Re: why i get these errors..
-
March 26th, 2009, 09:33 AM
#5
Re: why i get these errors..
in the end i write %*c
so it ignores of 1 char or the rest?
-
March 26th, 2009, 09:35 AM
#6
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´t #define them.
- Guido
-
March 26th, 2009, 09:41 AM
#7
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,"%20[^ ]%20[^ ]%20[^ ]%*c",a,b,c);
fclose(f);
return 0;
}
-
March 26th, 2009, 09:45 AM
#8
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,"%20s%20s%20s%*c",a,b,c);
fclose(f);
return 0;
}
-
March 26th, 2009, 01:18 PM
#9
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.
-
March 26th, 2009, 01:37 PM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|