Simple program not working

dose anyone know why this programs fails to compile?
it looks correct to me.

i am using gcc to compile
on xubuntu

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char caption[50];
char name[30];
int hp;
int lvl;
char choice[1];
FILE fp;

int main(int argc, char *argv[]){
	system("clear");
	printf("Enter Enemy name: ");
	fgets(name, 50, stdin);
	printf("\nEnter Enemy Caption: ");
	fgets(caption, 30, stdin);
	printf("\nEnter Enemy HP: ");
	scanf("%i", &hp);
	printf("\nEnter Enemy LVL: ");
	scanf("%i", &lvl);
	printf("\nname: %s", name);
	printf("caption: %s", caption);
	printf("HP: %i\n", hp);
	printf("LVL: %i\n", lvl);
	
	fp = fopen("btl.TTXT", "w");
	fprintf(fp, "%c", name);
	fprintf(fp, "%c", caption);
	fprintf(fp, "%i", hp);
	fprintf(fp, "%i", lvl);
	fclose(fp);
return 0;
}

thanks in advance
closed account (jvqpDjzh)
line 10: should be FILE* fp = NULL;//or FILE* fp;
Last edited on
The compiler does give an error message when the code has syntax error. Learn to read them.
sorry for being a bit lazy when posting this!
should of checked the compiler output!
thank you for replying though
Last edited on
Topic archived. No new replies allowed.