-
May 21st, 2013, 01:17 PM
#1
Files,question about data
Hi!!!!I have a question...How can I use the data from a file????For example at the following code I want to write a function that finds the max of the numbers i*n,that exist in the file "d.dat".How can I do this????Thank you!!!
#include <stdio.h>
int main()
{
FILE *fp;
int i,n;
fp = fopen("d.dat","w");
if (fp==NULL) {
exit(0);
}
for (i=0; i<=10; i++){
printf("Give number:");
scanf("%d",&n);
fprintf(fp,"%d,%d\n",n,i*n);
}
fclose(fp);
return 0;
}
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
|