1
I’m starting to use the Compile and there they use Linux. I’m having some problems such as printing a text file. Check my program, it works on windows:
#include<stdio.h>
/*
escreva um programa que leia o nome de 10 pessoas e armaene esses nomes no arquivo de texto nomes.txt
*/
int main()
{
FILE *arquivo;
int i;
char nome[40], c;
arquivo=fopen("nomes.txt", "a");
printf("digite os 10 nomes:\n");
for(i=0; i<10; i++)
{
gets(nome);
fprintf(arquivo,"%s \n",nome);
}
fclose(arquivo);
arquivo=fopen("nomes.txt", "r+");
while((c=getc(arquivo))!=EOF)
printf("%c",c);
return 0;
}
What’s different between writing on Linux and Windows so I can start using Fedora.
What’s the problem? Do you know if Compiler supports file writing? These sites do not usually give access to IO except the console that is redirected to the web page. The problem may be this.
– Maniero
"The biggest trick C has ever done is to convince the world that he doesn’t have a running time library". "The Greatest Trick that C Ever Pulled was convince the world that it does not have a Runtime". http://lucumr.pocoo.org/2013/8/18/beautiful-native-libraries/
– Tony
what I want to know is this
arquivo=fopen("nomes.txt", "r+");

while((c=getc(arquivo))!=EOF)
 printf("%c",c);
is to read in windows in lunux is like?– Leonardo V. De Gasperin
Except that you should NEVER wear
gets
, I see no error in your code and it should work normally on Linux and Windows. If you don’t post what error you’re getting, there’s no way we can help you anymore. I used Gentoo, I tested the code exactly as you wrote it and it worked.– Vinícius Gobbo A. de Oliveira