Hogyan kell c++ fájlkezelésben vesszővel egymásmellé kiíratni az adatokat?
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
Valami ilyesmivel probalkoznek (probald ki megy-e)
#include <stdio.h>
int main ()
{
char str [80];
float f;
FILE * pFile;
pFile = fopen ("myfile.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
{
do {
c = fgetc (pFile);
if (c == '/n ')
{
printf("%s",", ");
} else {
printf("%c", c);
}
} while (c!=EOF);
fclose (pFile);
return 0;
}
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
#include <stdio.h>
Bocs,
a deklaralast elszurtam, talan igy helyes lesz, a float-nak nem sok ertelme volt es c-t hasznaltam a vegen str helyett:
int main ()
{
FILE * pFile;
char c;
pFile = fopen ("myfile.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
{
do {
c = fgetc (pFile);
if (c == '/n ')
{
printf("%s",", ");
} else {
printf("%c", c);
}
} while (c!=EOF);
fclose (pFile);
return 0;
}
nemjó :\ ez van meg eddig:
#include <stdio.h>
int main()
{
int f,i;
FILE *je;
char nev[30];
je=fopen("jegyek.txt","r");
while(!feof(je))
{fgets(nev,20,je);
printf("%s",nev);
}
fclose(je);
while (getch()!=32);
}
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
Probald a kovetkezot ( [link] -on futtattam)
int main ()
{
FILE * pFile;
char c;
pFile = fopen ("myfile.txt","r");
if (pFile==NULL)
{
perror ("Error opening file");
}
else {
do {
c = fgetc (pFile);
if (c == 32)
{
printf("%s",", ");
} else {
printf("%c", c);
}
} while (c!=EOF);
}
fclose (pFile);
return 0;
}
További kérdések:
Minden jog fenntartva © 2025, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!