•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 402,056 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,360 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 206 | Replies: 1
![]() |
•
•
Join Date: Mar 2008
Posts: 19
Reputation:
Rep Power: 1
Solved Threads: 0
Hello
I have a list of data, which looks something like below
www.clickajob.co.uk%2Fprofiles%2F316%2F6%2F|a/TLT10911641168.google
www.ukdata.com%2Fcompany-listings%2FAd-16.html|a/TLT10911767856.google
I need to parse this data so i am left with
www.clickajob.co.uk|TLT10911641168.google
www.ukdata.com|TLT10911767856.google
Does anyone know how to help me? I have the following so far
I have a list of data, which looks something like below
www.clickajob.co.uk%2Fprofiles%2F316%2F6%2F|a/TLT10911641168.google
www.ukdata.com%2Fcompany-listings%2FAd-16.html|a/TLT10911767856.google
I need to parse this data so i am left with
www.clickajob.co.uk|TLT10911641168.google
www.ukdata.com|TLT10911767856.google
Does anyone know how to help me? I have the following so far
if ( fp == NULL )
{
printf("Error opening %s\n", filename );
return(1);
}
printf("Sucessfully opened %s\n", filename );
while(fgets(string,sizeof(string), fp )!= NULL )
{
printf("Start = %s\n", string );
if( ptr = strtok(string,"%"))
{
memcpy(web,ptr,sizeof(web));
printf("web = %s\n", web );
if ( ptr = strtok(NULL,"|" ))
{
printf("ptr = %\n", ptr );
memcpy(Company,ptr,sizeof(Company));
printf("BURN = %\n", Company );
}
}
}•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,694
Reputation:
Rep Power: 36
Solved Threads: 878
If the strings are always in that exact format than this should work.
int main()
{
char s1[] = "www.clickajob.co.uk%2Fprofiles%2F316%2F6%2F|a/TLT10911641168.google";
char s1a[50] = {0};
char* pos;
pos = strchr(s1,'%');
*pos++ = 0;
strcpy(s1a, s1);
pos = strchr(pos,'/');
strcat(s1a,"|");
strcat(s1a,pos+1);
printf("%s\n", s1a);
return 0;
} Last edited by Ancient Dragon : Jun 5th, 2008 at 11:19 am.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access advice broadband business classification code combo crime cult of the dead cow daniweb data data protection data transfer database drive dropdownlist encryption europe forensic forensics gadget google government hacking hard hardware help hitachi hp industrial espionage information internet linux mobile module net news payment services privacy protection reuse search security spot storage terabyte tutorials and more tv web wikipedia
- How to extract data from web databases? (Database Design)
- Msflexgrid data (Visual Basic 4 / 5 / 6)
- How do I work with data files? (C#)
- How to Grab the data from other websites? (PHP)
- reading in data (char, int.. etc) without return key (C)
- How to read data from csv file in an array and parse (C++)
- Multiple data being read in (C++)
- Parse error, unexpected T_STRING on line 26, but I don't see it (PHP)
Other Threads in the C Forum
- Previous Thread: copying binary files and setting permisions
- Next Thread: syntax error in conditional operator (?:)



Linear Mode