E
EkteGjetost
I would like to first apologize to those of you who read my last post
"desperately need help". As a regular on other forums i can understand how
aggravating it would be to have someone come on who obviously doesn't know
the community and asks for people to do their work for them.
So i've come much more prepared this time.
What my problem is, is that i need to write a program that will count the
number of alphabetic characters, numbers, punctuation marks, and spaces
from a text file.
Here's what i've done so far.
#include <stdio.h>
#include <ctype.h>
void countAlpha (FILE *infile, FILE *outfile, char alphabet);
void countDigit (FILE *infile, FILE *outfile, char numbers);
void countPunct (FILE *infile, FILE *outfile, char punctuation;
void countSpace (FILE *infile, FILE *outfile, char spaces);
int main()
{
FILE *infile;
FILE *outfile;
char alphabet = 0;
char numbers = 0;
char punctuation = 0;
char spaces = 0;
infile = fopen( "input.txt", "r");
if(infile == NULL)
{
printf("Cannot read input file: input.txt\n");
return 100;
}
outfile = fopen( "output.txt", "w");
if(outfile == NULL)
{
printf("Cannot open outputfile: output.txt\n");
return 100;
}
countAlpha(infile, outfile, alphabet);
countDigit(infile, outfile, numbers);
countPunct(infile, outfile, punctuation);
countSpace(infile, outfile, spaces);
return 0;
}
void countAlpha (FILE *infile, FILE *outfile, char alphabet)
{
fscanf(infile, "%c", alphabet);
while(isalpha(alphabet));
alphabet=getchar();
// i'm pretty sure this while loop is where the problem is
fprintf(outfile, "Alphabetic Characters: %c\n", alphabet);
and i just repeated the same things basically for each function after
that.
When i try to run this i get an error before what seems like anything else
happens.
"desperately need help". As a regular on other forums i can understand how
aggravating it would be to have someone come on who obviously doesn't know
the community and asks for people to do their work for them.
So i've come much more prepared this time.
What my problem is, is that i need to write a program that will count the
number of alphabetic characters, numbers, punctuation marks, and spaces
from a text file.
Here's what i've done so far.
#include <stdio.h>
#include <ctype.h>
void countAlpha (FILE *infile, FILE *outfile, char alphabet);
void countDigit (FILE *infile, FILE *outfile, char numbers);
void countPunct (FILE *infile, FILE *outfile, char punctuation;
void countSpace (FILE *infile, FILE *outfile, char spaces);
int main()
{
FILE *infile;
FILE *outfile;
char alphabet = 0;
char numbers = 0;
char punctuation = 0;
char spaces = 0;
infile = fopen( "input.txt", "r");
if(infile == NULL)
{
printf("Cannot read input file: input.txt\n");
return 100;
}
outfile = fopen( "output.txt", "w");
if(outfile == NULL)
{
printf("Cannot open outputfile: output.txt\n");
return 100;
}
countAlpha(infile, outfile, alphabet);
countDigit(infile, outfile, numbers);
countPunct(infile, outfile, punctuation);
countSpace(infile, outfile, spaces);
return 0;
}
void countAlpha (FILE *infile, FILE *outfile, char alphabet)
{
fscanf(infile, "%c", alphabet);
while(isalpha(alphabet));
alphabet=getchar();
// i'm pretty sure this while loop is where the problem is
fprintf(outfile, "Alphabetic Characters: %c\n", alphabet);
and i just repeated the same things basically for each function after
that.
When i try to run this i get an error before what seems like anything else
happens.