Q(1);
This is my code for reading in a number and storing it in a file.
but when i go to print out the number from the file it wont work.does anyone know why.

Q(2);
when the number is stored in a file it is stored as a string. How do i convert the string into a int value.



Code:
#include<stdio.h
void main()
{
FILE *fp;
char num[2];
char number[2];

printf("Enter Number");
scanf("%s",&number);
fp=fopen("file.txt","r+");

if(fp==NULL)
puts("Error in opening file.txt");
else
{
puts("file.txt is opened");
fputs(number,fp);
fgets(num,2,fp);
printf("%s",num);
fclose(fp);
}
}