It may be because its so late but I've started re-reading up on C and i've been messing around with structures and writing to files. Anyway I've been trying to save some structures to a file and they all work fine except for my char array =-(. Any help would be really awsome on the matter.
Code:
#include <stdio.h>
#include <string.h>
struct Player{
char name[100];
int hp;
int attack;
};
int main(){
//define all new Structures
struct Player player;
struct Player *playerPtr;
//Make all file readers + writers
FILE *PlayerSave;
PlayerSave = fopen("C:\\Users\\Adam Flax\\Documents\\test.txt", "r+");
player.name = "hello";
player.hp = 19;
player.attack = 17;
playerPtr = &player;
fprintf(PlayerSave,"%d\n", playerPtr -> name);
fprintf(PlayerSave,"%d\n", playerPtr -> hp);
fprintf(PlayerSave,"%d\n", playerPtr -> attack);
fclose(PlayerSave);
return(0);
}
thanks
zidsal
p.s
but ya I have not touched a programming language and its proberly something really stupid like player.name[0] ="hello"; (yes I have tried the obvoius).