basic file operations queries
I'm C Programming learner.
Please do clear my queries in detail.
< My PC config : Linux with GNU GCC compiler >
1) How to take a file as input which contains integers and display on screen.
I used the following code but its not working :
This is what I used and I'm getting errors. Instead If I replace 'int' by 'char' @ argv , @ num and replace %d by %c, its working..
# include <stdio.h>
int main ( int argc, int *argv )
fp_file = fopen ( argv, "r" );
but here the issue is that I'm getting only the first letter of the characters in the file on the screen. Even though I didn't give any white spaces.
I then replaced fscanf() and fprintf() functions with fputc and fgetc but the output is same.
how do I make sure that a) I get the whole characters without using arrays concept. b) how do I get numbers on my screen.
c) can't I use int type in declaring arguments in main function.
2) I want to take input a file which contain some number and my program should read and take that number into a declared variable. how to do it.
* also please give me tips how troubleshoot myself..