Hi!
Below is the code which can be use to read and display a simple extrenal file in C...But I am wondering How can i use pointers here and access this file via pointer
So the program above displaying content on screen, now assuming my .dat file has 500 rows and 1 column..how can use pointer and make every thing in a array which can be processed further
[CODE]
Below is what i think should work but its wrong
So how should i proceed it ! I think i need to go through pointers again!
Below is the code which can be use to read and display a simple extrenal file in C...But I am wondering How can i use pointers here and access this file via pointer
Code:
/* Display contents of a file on screen. */ # include "stdio.h" int main(void ) { FILE *fp ; char ch ; fp = fopen ( "sinfft.dat", "r" ) ; while ( 1 ) { ch = fgetc ( fp ) ; if ( ch == EOF ) break ; printf ( "%c", ch ) ; } fclose ( fp ) ; return 0; }
So the program above displaying content on screen, now assuming my .dat file has 500 rows and 1 column..how can use pointer and make every thing in a array which can be processed further
[CODE]
Below is what i think should work but its wrong
Code:
/* Display contents of a file on screen. */ # include "stdio.h" int main(void ) { int *in; array[500]={}; in=&array; FILE *fp ; char ch ; fp = fopen ( "sinfft.dat", "r" ) ; while ( 1 ) { ch = fgetc ( fp ) ; if ( ch == EOF ) break ; printf ( "%c", ch ) ; } fclose ( fp ) ; for(in=0;in<=500;*in++);{ printf("Array is %f", in); } return 0; }
So how should i proceed it ! I think i need to go through pointers again!