ur code is working fine but what is the problem is that i am not getting the exact readings. the last 240 is correct but the upper one is showing different readings. so I am checking it. U just be online please.
MK27..now the readings are fine but i used unsigned to display the minus sign too but while doing this i am getting different values after DewPointC. I got correct values for Time and DryPointC but for DewPointC i got all 0 and for RH i am getting some garbage values.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
i didnot get u. So now how should i change the codes?
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Code:#include <stdio.h> #include <string.h> int main() { int Time, RH, retv; signed DewPointC; float DryTempC; char line[256]; int i; FILE *in = fopen("KBIS_2005.txt", "r"); for(i = 0; i<=240; i++) { fgets(line,256,in); retv=sscanf(line,"%d %f %f %d",&Time,&DewPointC,&DryTempC,&RH); printf("%d items read: %d %f %f %d\n",retv,Time,DewPointC,DryTempC,RH); } return 0; }
Ah. Well, this is not a real datatype:
Just make it a float!Code:signed DewPointC;
That should not compile at all, by the way. What compiler are you using?
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
i used float too but while using it I am not getting the correct readings. Again I will try. I am using gcc compiler at linux.
Code:#include <stdio.h> #include <string.h> int main() { int Time, RH, retv; float DewPointC; float DryTempC; char line[256]; int i; FILE *in = fopen("KBIS_2005.txt", "r"); for(i = 1; i<=241; i++) { fgets(line,256,in); retv=sscanf(line,"%d %f %f %d",&Time,&DewPointC,&DryTempC,&RH); printf("%d items read: %d %f %f %d\n",retv,Time,DewPointC,DryTempC,RH); } return 0; } thnks now i am getting the correct readings. but i am getting wrong garbage values at the beginning. so how should i remove it.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
yah i got it..but i am stil getting the garbage value at the beginning.how to delete those?
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
i should not be getting the first values. I tried to change the values in the for loop but it is still reading that values.Code:0 items read: 0 0.000000 0.000000 4196133 4 items read: 0 0.600000 -5.000000 67 4 items read: 1 0.000000 -3.900000 75 4 items read: 2 0.000000 -3.900000 75