473,513 Members | 2,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading external File or File processing in C

7 New Member
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
Expand|Select|Wrap|Line Numbers
  1.  
  2. /* Display contents of a file on screen. */
  3. # include "stdio.h"
  4. int main(void )
  5. {
  6.      FILE *fp ;
  7.      char ch ;
  8.      fp = fopen ( "sinfft.dat", "r" ) ;
  9.      while ( 1 )
  10.      {
  11.           ch = fgetc ( fp ) ;
  12.           if ( ch == EOF )
  13.                 break ;
  14.           printf ( "%c", ch ) ;
  15.      }
  16.      fclose ( fp ) ;
  17.      return 0;
  18. }
  19.  
  20.  
  21.  

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
Expand|Select|Wrap|Line Numbers
  1. /* Display contents of a file on screen. */
  2. # include "stdio.h"
  3. int main(void )
  4. {
  5.  
  6.      int *in;
  7.      array[500]={};
  8.      in=&array;
  9.      FILE *fp ;
  10.      char ch ;
  11.      fp = fopen ( "sinfft.dat", "r" ) ;
  12.      while ( 1 )
  13.      {
  14.           ch = fgetc ( fp ) ;
  15.           if ( ch == EOF )
  16.                 break ;
  17.           printf ( "%c", ch ) ;
  18.      }
  19.      fclose ( fp ) ;
  20.  
  21.      for(in=0;in<=500;*in++);{
  22.       printf("Array is %f", in);
  23. }
  24.  
  25. return 0;
  26. }
  27.  
  28.  

So how should i proceed it ! I think i need to go through pointers again!
Jun 2 '10 #1
0 1257

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2026
by: Tomislav Bilic | last post by:
Hello, I need to parse one XML file that has size of 600Mb. Parsing itself is not a problem. Problem occures while reading the file that large. Here is the code: function...
2
1278
by: Rolf | last post by:
Hallo here I like to read a external data file.( text file ) But the data is not consistent. As you see in 1 line ther is the word 'ceasing' but not in the other
38
3964
by: Neo Geshel | last post by:
I am seeking a method to load one JS file directly into another, *without* having to dynamically write <scripttags. Is there any method whereby I can call only one external JS file using a ...
3
1822
by: RICHARD BROMBERG | last post by:
I have a simple program to test using an external .js file. This external file contains some functions that I need to call from several html programs. The program as written below works fine. ...
1
2309
by: anii | last post by:
Hi! I'm working on a piece of code for school. =) in C++. (I've read the rules and understand that i can't put all of the code here and ask for all of the code) I've got all (or most) of the code...
5
1476
by: yoel | last post by:
Hey: I have: <head><script language="javascript" type="text/javascript" src="sideMenu.js"></script></head> and <body><script> document.write(doThis('')); </script></body>
13
3660
by: swetha | last post by:
HI Every1, I have a problem in reading a binary file. Actually i want a C program which reads in the data from a file which is in binary format and i want to update values in it. The file...
2
6119
by: murthydb2 | last post by:
Hi My requirement is that i have to write a stored procedure in db2 and that will be executed in a batch file . Any system error or validation error that occurs inside the db2 sp during...
0
3880
by: whochrisporter | last post by:
Hi, thanks for reading and helping me first of all. Now to the question.. I need to load external images into a scrolling slideshow (its like a sliding rotating banner) flash file using an...
2
2826
by: Derik | last post by:
I've got a XML file I read using a file_get_contents and turn into a simpleXML node every time index.php loads. I suspect this is causing a noticeable lag in my page-execution time. (Or the...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.