C Assignment
I am suppose to make a programme that counts the number of vowels in an input file. Can somebody please tell me what I am doing wrong on this assignment? PLEASE!?
Here is what I am trying to print:
Sample output:
a: 48: **************************************** ********
e: 49: **************************************** *********
i: 48: **************************************** ********
o: 42: **************************************** **
u: 17: *****************
Here is my code:
#include
Here is what I am trying to print:
Sample output:
a: 48: ****************************************
e: 49: ****************************************
i: 48: ****************************************
o: 42: ****************************************
u: 17: *****************
Here is my code:
#include
[Error: Irreparable invalid markup ('<stdio.h>') in entry. Owner must fix manually. Raw contents below.]
I am suppose to make a programme that counts the number of vowels in an input file. Can somebody please tell me what I am doing wrong on this assignment? PLEASE!?
<lj-cut text="PRoblem">
Here is what I am trying to print:
Sample output:
a: 48: ************************************************
e: 49: *************************************************
i: 48: ************************************************
o: 42: ******************************************
u: 17: *****************
Here is my code:
#include <stdio.h>
int main()
{
FILE* infile = fopen("vowels.in", "r");
FILE* outfile = fopen("vowels.out", "w");
int a,e,i,o,u,j;
a=0;
e=0;
i=0;
o=0;
u=0;
char current;
while(1)
{
fscanf(infile, "%c", ¤t);
if(current == "a");
a++ ;
if(current == "e")
e++ ;
if(current == "i")
i++ ;
if(current == "o")
o++ ;
if(current == "u")
u++ ;
if(feof(infile)) break;
}
fprintf(outfile, "a: %d: ", a);
for(j=0; j<=a; j++)
{
fprintf(outfile, "*");
}
fprintf(outfile, "\ne: %d: ", e);
for(j=0; j<=e; j++)
{
fprintf(outfile, "*");
}
fprintf(outfile, "\ni: %d: ", i);
for(j=0; j<=i; j++)
{
fprintf(outfile, "*");
}
fprintf(outfile, "\no: %d: ", o);
for(j=0; j<=o; j++)
{
fprintf(outfile, "*");
}
fprintf(outfile, "\nu: %d: ", u);
for(j=0; j<=u; j++)
{
fprintf(outfile, "*");
}
return 0;
}
Here are my errors:
Compiling...
c:\docume~1\bruce\mydocu~1\programs\vowels.c
c:\docume~1\bruce\mydocu~1\programs\vowels.c(15) : error C2143: syntax error : missing ';' before 'type'
c:\docume~1\bruce\mydocu~1\programs\vowels.c(19) : error C2065: 'current' : undeclared identifier
c:\docume~1\bruce\mydocu~1\programs\vowels.c(20) : warning C4047: '==' : different levels of indirection
c:\docume~1\bruce\mydocu~1\programs\vowels.c(22) : warning C4047: '==' : different levels of indirection
c:\docume~1\bruce\mydocu~1\programs\vowels.c(24) : warning C4047: '==' : different levels of indirection
c:\docume~1\bruce\mydocu~1\programs\vowels.c(26) : warning C4047: '==' : different levels of indirection
c:\docume~1\bruce\mydocu~1\programs\vowels.c(28) : warning C4047: '==' : different levels of indirection
CL returned error code 2.
VOWELS.C - 2 error(s), 5 warning(s)
</lj-cut>
<lj-cut text="PRoblem">
Here is what I am trying to print:
Sample output:
a: 48: ************************************************
e: 49: *************************************************
i: 48: ************************************************
o: 42: ******************************************
u: 17: *****************
Here is my code:
#include <stdio.h>
int main()
{
FILE* infile = fopen("vowels.in", "r");
FILE* outfile = fopen("vowels.out", "w");
int a,e,i,o,u,j;
a=0;
e=0;
i=0;
o=0;
u=0;
char current;
while(1)
{
fscanf(infile, "%c", ¤t);
if(current == "a");
a++ ;
if(current == "e")
e++ ;
if(current == "i")
i++ ;
if(current == "o")
o++ ;
if(current == "u")
u++ ;
if(feof(infile)) break;
}
fprintf(outfile, "a: %d: ", a);
for(j=0; j<=a; j++)
{
fprintf(outfile, "*");
}
fprintf(outfile, "\ne: %d: ", e);
for(j=0; j<=e; j++)
{
fprintf(outfile, "*");
}
fprintf(outfile, "\ni: %d: ", i);
for(j=0; j<=i; j++)
{
fprintf(outfile, "*");
}
fprintf(outfile, "\no: %d: ", o);
for(j=0; j<=o; j++)
{
fprintf(outfile, "*");
}
fprintf(outfile, "\nu: %d: ", u);
for(j=0; j<=u; j++)
{
fprintf(outfile, "*");
}
return 0;
}
Here are my errors:
Compiling...
c:\docume~1\bruce\mydocu~1\programs\vowels.c
c:\docume~1\bruce\mydocu~1\programs\vowels.c(15) : error C2143: syntax error : missing ';' before 'type'
c:\docume~1\bruce\mydocu~1\programs\vowels.c(19) : error C2065: 'current' : undeclared identifier
c:\docume~1\bruce\mydocu~1\programs\vowels.c(20) : warning C4047: '==' : different levels of indirection
c:\docume~1\bruce\mydocu~1\programs\vowels.c(22) : warning C4047: '==' : different levels of indirection
c:\docume~1\bruce\mydocu~1\programs\vowels.c(24) : warning C4047: '==' : different levels of indirection
c:\docume~1\bruce\mydocu~1\programs\vowels.c(26) : warning C4047: '==' : different levels of indirection
c:\docume~1\bruce\mydocu~1\programs\vowels.c(28) : warning C4047: '==' : different levels of indirection
CL returned error code 2.
VOWELS.C - 2 error(s), 5 warning(s)
</lj-cut>
