Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Parsing a Comma Separated String in C

Reply
Thread Tools

Parsing a Comma Separated String in C

 
 
ronan_40060 ronan_40060 is offline
Junior Member
Join Date: Sep 2006
Posts: 1
 
      09-06-2006
Dear friends

How do i write a small C function which accepts a comma separated string . the string could be either like ("Hi", "How", "You" ) or hi, how, are, you . nad parse it and output should be displayed like
hi
how
are
you
How to split the string on the first value and stored it in a separete string variable and display it
Thanks
Ronan
 
Reply With Quote
 
 
 
 
Rudresh R kaddipudi Rudresh R kaddipudi is offline
Junior Member
Join Date: Nov 2006
Location: Bangalore
Posts: 4
 
      12-22-2006
char *str="hi,how,are,you";
char *val; int i,j=0;

while((str+j)!='\0'){

i=0;

while(*(str+j)!=',')
{
*(val+i)=*(str+j);
j++;
i++;
}
printf("%s",val);
j++;
}
}

hope it would be helpful
 

Last edited by Rudresh R kaddipudi; 12-22-2006 at 11:18 AM..
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing a comma-separated file Justin To Ruby 10 06-09-2008 11:54 PM
returning the Fibonacci string separated by comma mac C Programming 17 02-14-2007 05:43 PM
How to stream a comma separated string to the browser? =?Utf-8?B?Q2hyaXMgTGFuZQ==?= ASP .Net 1 07-21-2006 07:00 PM
Parsing comma-separated values with XSL? RogerTBrick XML 3 03-07-2005 10:07 AM
Array to a comma Separated String Peter Rilling ASP .Net 3 07-08-2004 05:53 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57