L
leeho94
hello everyone.
Who can help me telling me what's wrong in the following code?
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define BUFSIZE 1024
#define max 1000
void write(char *sentence);
FILE *fin,*fout;
enum gulja {man,me,ne};
const char * guljas[]= {"man","me","ne"};
int main(int argc, char* argv[])
{
enum gulja gul;
char delims[] = " ";
char *result;
char *str;
char name;
int i=0;
static char temp[BUFSIZE];
int fc1;
str = (char*)malloc(sizeof(char));
printf("File input:");
scanf("%s",&name);
fin=fopen(&name,"r");
fread(str,sizeof(char),BUFSIZE,fin);
result = strtok( str, delims );
fout = fopen("result.txt","a");
while(result != NULL)
{
if(strcmp(gul,result))==0){
switch(gul)
{
case 0 : fprintf(fout,"³ª", result );
break;
case 1 : fprintf(fout,"»ç¶÷", result );
break;
case 2 : fprintf(fout,"±Û½ê", result );
break;
case '4' : fprintf(fout,"4", result );
break;
case '5' : fprintf(fout,"5", result );
break;
default : fprintf(fout,"6", result );
break;
}
}
result = strtok( NULL, delims );
fc1 = fclose(fout);
return 0;
}
void write(char *sentence)
{
fprintf(fout,"%s",sentence);
}
Who can help me telling me what's wrong in the following code?
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define BUFSIZE 1024
#define max 1000
void write(char *sentence);
FILE *fin,*fout;
enum gulja {man,me,ne};
const char * guljas[]= {"man","me","ne"};
int main(int argc, char* argv[])
{
enum gulja gul;
char delims[] = " ";
char *result;
char *str;
char name;
int i=0;
static char temp[BUFSIZE];
int fc1;
str = (char*)malloc(sizeof(char));
printf("File input:");
scanf("%s",&name);
fin=fopen(&name,"r");
fread(str,sizeof(char),BUFSIZE,fin);
result = strtok( str, delims );
fout = fopen("result.txt","a");
while(result != NULL)
{
if(strcmp(gul,result))==0){
switch(gul)
{
case 0 : fprintf(fout,"³ª", result );
break;
case 1 : fprintf(fout,"»ç¶÷", result );
break;
case 2 : fprintf(fout,"±Û½ê", result );
break;
case '4' : fprintf(fout,"4", result );
break;
case '5' : fprintf(fout,"5", result );
break;
default : fprintf(fout,"6", result );
break;
}
}
result = strtok( NULL, delims );
fc1 = fclose(fout);
return 0;
}
void write(char *sentence)
{
fprintf(fout,"%s",sentence);
}