Hello,
I want to make program which will write characters from input into a file "soubor.txt" with spaces and diacritic and I would like to know what am I doing wrong here in my code, because output, when I writeis:Code:AhojThis is code:Code:#v·^Gv·^G·^G^G
Code:#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define MAX 500 int main(void) { fflush(stdin); FILE *soubor; int i,j; char c[MAX]; j = 0; soubor = fopen("soubor.txt", "w"); for(i=0;i<=MAX;i++) { c[i] = getchar(); if(!(isalpha(c[i])) || !(isdigit(c[i]))) { c[i] = '\0'; } if(c[i] == '\0') { break; } } for(j=0;j<=MAX;j++) { if(isspace(c[j])) { c[j] = ' '; break; } fputs(&c[j], soubor); } fclose(soubor); return 0; }



LinkBack URL
About LinkBacks



