The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Reading a file.
Discuss Reading a file. in the C Programming forum on Dev Shed. Reading a file. C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 3rd, 2003, 01:57 AM
|
|
Junior Member
|
|
Join Date: Nov 2002
Location: Mumbai
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Reading a file.
I have to read a particular file which is Ansys generated and in a particular format...I am attaching the file that has to be read.Actually I was not allowed to attach a simple txt file so I have taken a screen print of my file and attached that.The file is a Wordpad file.As I am not very conversant with C and I've been given this small assignment to be completed urgently,I would be very very grateful if any of you could mail me the code for doing this.
Here's what is to be done...
I need to find out what are the numbers corresponding to a line.For eg. the corresponding numbers for line 1 are 29,30,20,21,18,4,24,26,22.Line 2 only has 6,3,4,5.Line 3 has 31,28,9,7 and 10...and so on.The 0's after N/A are to be ignored and the first 1 for each line is to be ignored.
Thanks in advance for any help.
|

June 3rd, 2003, 02:12 AM
|
|
Contributing User
|
|
Join Date: Feb 2001
Posts: 1,365

Time spent in forums: 18 h 9 m 25 sec
Reputation Power: 14
|
|
|
"Actually I was not allowed to attach a simple txt file"
Did it ever cross your mind that this forum is text format?
|

June 3rd, 2003, 02:21 AM
|
|
Junior Member
|
|
Join Date: Nov 2002
Location: Mumbai
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
If I tried to send the file by pasting it here,the formatting would be lost.It wasn't even a txt file really.It was a .lis file generated by Ansys which I used to open with Wordpad.That apart,I would be grateful if anyone could provide a solution to my problem.
Thanks,
-Ekta.
|

June 3rd, 2003, 03:55 AM
|
|
Offensive Member
|
|
Join Date: Oct 2002
Location: in the perfect world
|
|
depends on the target OS. Something like this will do the job.
Code:
OpenFile
FindFilesize
AllocFileBuffer
AllocDataArray
ReadFile
CloseFile
Set pointer to start of file
while(not at end of file)
find line number
set right data array element
while(not end of line)
move filepointer until next digit
atoi (file pointer)
if(data validated)
copy into data array
if you want full working code it will cost you............
Post your attemp and someone will help if they can.
__________________
The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.
Frank Zappa
|

June 3rd, 2003, 03:57 AM
|
|
Junior Member
|
|
Join Date: Nov 2002
Location: Mumbai
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Thanks Technofear
Thanks a lot for your help Technofear...That was really helpful.Thanks again.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|