hello you.
Code:
/* an array will be printed in the desired file.
fputs doesnt work with count() function. why?
*/
#include<stdio.h>
#include<conio.h>
int count();
main ()
{
FILE *datei; //filename declared
int hello[100]; //this is going to be printed
int i, stop;
char filename[20];
int count();
printf("enter filename: ");
scanf("%s", &filename);
datei = fopen (filename, "w+");
if (datei == NULL)
printf("an error occured\n");
else
printf("an one dimensional array is going to be printed in your file\n\n");
fputs(count(), datei); //this line is supposed to write
//the return values of int count()
// to the file called datei
scanf("%d", &stop); //this line only exists to stop
//the program, no deeper sense
return 0;
}
int count()
{
int i, hello[100] ;
for(i=0;i<=100;i=i++)
hello[i] = 10;
for(i=0;i<=100;i++)
printf("%d\n", hello[i]);
return(hello[i]);
}
this code is a little documented, so you can easier understand the purpose of this program.
the fputs line doesnt work with the function.
i typed: fputs(count(), datei);
my compiler doesnt seem to like it.
how do i print a whole function to a file? this time the count() function.