+ 1
New line problem...Help
*/guys ı created file named "dosya" and wirte these things= Elon Musk Jeff Bezos Trump but every new name is on the new line but this code runs it like: Elon Musk jeff Bezos ... I want to make them like: Elon musk Jeff bezos ....*/ #include <stdio.h> #include <stdlib.h> int main(){ FILE *dosya; char Ismi[50][50]; int index=0; printf("LIST 1\n"); if ((dosya =fopen("dosya.txt","r"))!= NULL){ while (!feof(dosya)){ fscanf(dosya, "%s ",&Ismi[index]); index++; } for(int i=0;i<index;i++){ printf(" %s \n ",Ismi[i]); } } else { printf("not found"); } fclose(dosya);
2 Respuestas
+ 3
Abc def Please move your code in code bits. and link your code URL that way you could get much help
+ 1
If you know that everyone in the file has exactly a one-word name and a one-word surname, then scan two words and print them with a newline at the end.
If your file might contain people like "God" or "Diego Armando Maradona" you can use getline()
If yor file contains people, like "Pablo Diego José Francisco de Paula Juan Nepomuceno Cipriano de la Santísima Trinidad Ruiz Picasso", whose name takes more than one line, then you need a signal at the end of the person. Like a comma or a period.