LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-27-2004, 01:06 PM   #1
liguorir
Member
 
Registered: May 2003
Posts: 256

Rep: Reputation: 30
Question C Conversion Program


Can someone please show me some C code that would convert this:


{
FIELD_0: 00:00:01
FIELD_1: hello
FIELD_2: world
}
{
FIELD_3: hi
FIELD_4: planet
}


to this:


00:00:01
==hello world
==planet
 
Old 01-27-2004, 01:12 PM   #2
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Where did the "hi" go?

Rather than just giving you some code, I'll give you some suggestions: Look into the C function called strtok(), which takes a C-style character array and splits it up based on a delimiting character. You could use strtok() to break each line up and get the value of the fields.

Without knowing how generalized you want your algorithm to be, though, you could do it in a simpler way by just searching through each line until you find a ":", and then reading in everything after that for the value of the field.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any Good Conversion Program? caesium5 SUSE / openSUSE 6 09-01-2005 12:56 PM
C Program Problem (temp conversion) username17 Programming 11 05-16-2005 02:57 PM
Total Conversion? guy Linux - Hardware 4 11-25-2003 07:54 PM
double conversion Xiangbuilder Programming 15 10-09-2003 10:12 AM
File Conversion justaguynsrq Slackware 4 05-26-2003 08:10 PM


All times are GMT -5. The time now is 03:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration