#include
#include
#include
using namespace std;
struct wartosci{
float czas;
float sila;
float predkosc;
};
void przekaz(wartosci *dane){
FILE *pFile;
pFile = fopen ("kom.txt" , "r");
char x1[100],x2[100],x3[100],x4[100],x5[100],x6[100],x7[100],txt,txt1,txt2;
fgets(x1, 100, pFile);
fgets(x2, 100, pFile);
fgets(x3, 100, pFile);
fgets(x4, 100, pFile);
fgets(x5, 100, pFile);
fgets(x6, 100, pFile);
fgets(x7, 100, pFile);
/* cout<
cout<
cout<
cout<
cout<
cout<
cout<
*/
sscanf(x2,"%s %f",txt,&dane->czas);
sscanf(x4,"%s %f",txt1,&dane->sila);
sscanf(x7,"%s %f",txt2,&dane->predkosc);
fclose (pFile);
}
int main(int argc, char *argv[])
{
wartosci dane;
wartosci *pwartosci;
pwartosci=&dane;
FILE * pFile;
pFile = fopen ("kom.txt" , "r");
przekaz(&dane);
fclose (pFile);
system("pause");
return 0;
}
.txt
#komentarz1
czas 0.1
#komentarz 2
sila 99.4
#sd
#
# komentarz 3
predkosc 4.5
program sie wysypuje - nie pokazuje bledu, sprawdzalem w visualu
Run-Time Check Failure #3 - The variable 'pFile' is being used without being initialized.
troszke pozmienialem ale wciaz to samo, wysypuje sie na sscanf nie mam pojecia czy to wciaz ten sam blad
program ma przepisac wartosci do struktury, chcialem na poczatku zrobic to troche porzadniej typu wczytywanie wszystkich lini w petli nastepnie zignorowanie wszystkich lini rozpoczynajacych sie od # , ale juz poszedlem troche na lenia i tak zostalo
mam jeszcze jedno pytanie gdzie w dev c++ znajde cos takiego jak breakpoint ktory jest na wierzchu w visualu ?