hey please help me execute the code on ubuntu in C
#include<stdio.h>
#include<stdlib.h>
int main()
Usually you would use int main(void)
You do not appear to use 'ch', so you might as well get rid of it.
float ticktock;
int val;
fp=fopen("pt1.txt","rb");
You fail to check to see whether the open succeeded by checking
the value of fp after the fopen().
feof() in C never makes a -prediction- about whether the next read
would work or not (the fact that no data is available in the buffer
right now does not mean that end of file has been reached -- you
might be connected to a network socket or the action of asking for
more data might cause more data to be released to you.) Therefore
testing for feof() first before the read does not work:
instead you need to check the return value of each file read
to see whether you got the data you wanted.
{
sscanf(fp, "time=%f value=%d", &ticktock, &val);
printf("%f",ticktock);
printf("%d",val);
Typically if you have two successive printf()'s, you would merge
them into a single call, such as
printf("%f%d, ticktock, val);
Oh dear, you did not include any spacing between the output
values and you do not include and line termination characters.
Everything is going to be output as a single long string of
digits (with some decimal points in places.)
You declared main as returning an int but you failed to return
any value. That gives undefined behaviour for C90 (but will work
in C99.)
please send reply as soon as possible its urgent
http://www.officeplayground.com/lackplanning.html