I have this simple program that counts characters in a line as well as a specific character z and Z. I am trying to figure out the simplest way to output my results to a file "outfile.txt". any ideas?
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
char string[80];
char *s;
int count=0;
int len;
int zcount=0;
}
printf("Enter string: ");
gets(string);
len=strlen(string);
printf("The length of your sentence is %d characters long\n",len);
for(s = string; *s != '\0'; s++)
{
if((*s == 'z') || (*s == 'Z'))
zcount++;
}
printf("Number of z's in your sentence are %d",zcount);
getchar();
return(0);
}