problem
-
I read from a file , when I reach : <#if ... #> when the " ... "(something) is short the fgets function reads true but when the " ... "(something) is a little longer the fgets function read incorect what is the problem??? thank you
if you look at the fgets()[^] function behavior, it waits for a "maximum characters to read" parameter ; so i believe that your problem comes from the length of your buffer (if you read a line which is wider that your buffer, it will be truncated)
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-
if you look at the fgets()[^] function behavior, it waits for a "maximum characters to read" parameter ; so i believe that your problem comes from the length of your buffer (if you read a line which is wider that your buffer, it will be truncated)
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-
no , i put n=1000 and ... is less than 100 characters . and also when i read : dsalgujbslgkusdhglidsufhgllkufg it is true but <#if dsgubsldfjgblfdgbldfgb #> is false !!!!!!!!!!!!!!!!!!!!!!!!! i dont know why fgets act like this .
use you debugger to compare the string you read and what is actually filled in your buffer. btw, do you have any \n, spaces or escape characters in the string read ?
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-
use you debugger to compare the string you read and what is actually filled in your buffer. btw, do you have any \n, spaces or escape characters in the string read ?
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
I haven't any '\n' , space and scape . this is what happens : the file is: <#if...#> hello the code is: --------------- debugger shows :
char string[1000]=""; // string = "" > fgets("adress",1000,input); // string = "<#if.." fgets("adress",1000,input); // string = "<#if.."
-
I haven't any '\n' , space and scape . this is what happens : the file is: <#if...#> hello the code is: --------------- debugger shows :
char string[1000]=""; // string = "" > fgets("adress",1000,input); // string = "<#if.." fgets("adress",1000,input); // string = "<#if.."
-
AH ofcourse it was a misprint , it is true in my code . -- modified at 8:54 Tuesday 6th June, 2006
Can you post your code ? (With the opening of the file also)
Cédric Moonen Software developer
Charting control -
AH ofcourse it was a misprint , it is true in my code . -- modified at 8:54 Tuesday 6th June, 2006
I think you should provide the entire fragment between the line where you open the file (
fopen
) and close it (fclose
), and may be a precise content of input file. Perhaps, someone will figure out the problem. If your program is too big, try to remove (comment) some fragments, keeping file-processing only. Thus you should be able to reproduce the problem for a smaller program. -
I haven't any '\n' , space and scape . this is what happens : the file is: <#if...#> hello the code is: --------------- debugger shows :
char string[1000]=""; // string = "" > fgets("adress",1000,input); // string = "<#if.." fgets("adress",1000,input); // string = "<#if.."
How are you verifying the contents of
string
?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
-
Can you post your code ? (With the opening of the file also)
Cédric Moonen Software developer
Charting control -
Just post the relevant information here (the code snippet that opens and read from the files with the variables that are used). Please use the code tags (above the emoticons)
Cédric Moonen Software developer
Charting control -
Just post the relevant information here (the code snippet that opens and read from the files with the variables that are used). Please use the code tags (above the emoticons)
Cédric Moonen Software developer
Charting controlcode is :
int main()
{
char khat[1000];
clrscr();
int i;
for(i=0;i<1000;i++) {khat[i]='\0'; if(i<100)counter[i]=0;}
FILE *f;
f=fopen("falle//in2.htm","r");
for(i=1;i<1000;i++)
{
fgets(khat,1000,f);
// here you can see the khat string
printf("%s\n",khat);
if(strcmp(khat,"")==0) break;
}
fclose(f);
char ch=getch();
if(ch==27) return 0;
return 0;
}and file is :
<#if( 1+2^3 < 2*(2+3)+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1 )#>
correct
yes , it is correct
<#fi#>
incorect
<#loop 4#>
this is in the loop
and number is :
<#i#>
<#do#>