Hello, I am new to this place. Could you help me wit the following problem. Well the Pointer I trie to print in main doesn't show the content I have in the txt-File. I think I would feel better if I had an Array of Numbers instead of Chars after reading in the txt-File which only contains numbers, seperated with a "space bar".
Code:
int main(){
//einige Standard-Variablen
int i = 0;
int j = 0;
int z = 4;
//here I want to pass the Pointer from the Funktion to to another Pointer in Main
char * pSpielstaerken;
pSpielstaerken = einlesen();
//THIS IS THE PROOF, THAT IT DOESN'T WORK
while( pSpielstaerken[i] != '\0' ){
printf( "%i ", pSpielstaerken[i] );
i++;
}
}
//this is the Function to Read in a txt-File, pass it to a Char-Array in order to return it finally to the main Function
char * einlesen(){
FILE * input2;
char charPuffer[50];
char * pCharpuffer;
pCharpuffer = &charPuffer[0];
input2 = fopen("input2.txt","r");
if (input2==NULL){
printf ("Fehler beim Einlesen");
}
else {
fgets (charPuffer, 50, input2);
fclose (input2);
}
int i = 0;
return (pCharpuffer);
}