943,693 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 5500
  • C RSS
Aug 4th, 2004
0

problem with convert jumbled text file to unjumbled text file

Expand Post »
as title mentioned, i face problem with convert a jumbled text file to unjumbled text file, some of you might not clear what i am saying, well a example will give a clear idea what this all about.

jumbled text file contain a few line of number,
after unjumbled it, a cute bear will show up...

seriously i dun have any idea how to do this...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
zrixter is offline Offline
1 posts
since Aug 2004
Aug 5th, 2004
0

Re: problem with convert jumbled text file to unjumbled text file

Was this an assignment from someone? And they didn't give you any hints or instructions on HOW to convert the numbers to something that represents a bear? That doesn't sound fair!

Did they give you the file with numbers in it? What does the first two or three lines look like?
Reputation Points: 36
Solved Threads: 11
Posting Pro in Training
Chainsaw is offline Offline
436 posts
since Jun 2004
Aug 6th, 2004
0

Re: problem with convert jumbled text file to unjumbled text file

Ok,that can be done quite easily if you know your file handling and a little bit of char manipulation.

If you want a tutorial on file handling then here is a link.
http://www.daniweb.com/techtalkforums/thread6542.html

Now here is an idea on how to do it.

1.First open the jumbled file
2.Open an output file
3.Read a line from the jumbled file

Now let the line be like:12 0000000XX0000XXXXXX

4.Get the line no (i.e 12) by copying the letter for the read line till you reach a space
5.If the number is the current line (i.e 1) then write to output file
6.Do this till all the lines are done and keep repeating the jumbled file reading.


Ok simple eh,but it's not too good or efficient but should do the job.Also to convert a char array which holds a num like "2324" into a int use atoi() (#include stdlib.h)

char char_num[] = "sdfsd";
int x = atoi(char_num);
Reputation Points: 108
Solved Threads: 7
Posting Whiz in Training
FireNet is offline Offline
256 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Help a new member
Next Thread in C Forum Timeline: message passing interfaces





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC