Getting Variable from txt file

Hey, I have little problem getting variable from txt file..

I have already tried code like

1
2
3
4
5
6
7
FILE *tiedosto;
char tiedostonimi[] = "input.txt";
tiedosto = fopen (tiedostonimi, "r");
char luokka, kaupunki[4];
int kuutio, vuosi, kuukausi, paiva;

fscanf(tiedosto, "%i&energialuokka=%c&kaupunki=%s&Vuosi=%i&Kuukausi=%i&pva=%i", &kuutio, &luokka, &kaupunki, &vuosi, &kuukausi, &paiva);


I just cant get what I'm doing wrong..

Inside my txt file is line:
 
22&energialuokka=A&kaupunki=ei&Vuosi=2010&Kuukausi=02&pva=22

"22" "A" "ei" "2010" "02" "22" are not permanent values.. (given values via cgi and saved into file)

I want variables like:
Int number = 22;
char character = A;
char character2 = ei;
int number2 = 2012;
int number3 = 02;
int number4 = 22;

I Woud be happy if someone can help me out with this issue.. :/
Last edited on
Topic archived. No new replies allowed.