Computing.Net > Forums > Programming > Text technique please help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Text technique please help

Reply to Message Icon

Name: Tsunami_Spirit
Date: August 27, 2003 at 12:31:30 Pacific
OS: Windows ME 4.90.3000
CPU/Ram: Intel Celeron 900Hz/128 m
Comment:

I have got a text file which a lot of useless texts in brackets i.e. (something). There are no nested braket at all. Can something help me to figure out a script in VB or C++ that can delete all occurrences of brackets and stuffs inside them without the layout of the text. I appreciate your help in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: jorgen
Date: August 27, 2003 at 15:16:28 Pacific
Reply:

You can use this function to delete any text, including the open and close chars, between any two chars (brackets, etc.).

You pass it a buffer that is 10 bytes longer than the text file you want to read into it and zeroed ( c++: new() or c: calloc() ).

Write 'buf' back out to a file to see your modifications.


#include <string.h>

int delbrackets(
char *buf,
char openC,
char closeC)
{
char *p,*q;

for(p=q=buf;*p;)
{
p=strstr(p,openC);
if(p==NULL)return 0;

q=strstr(p,closeC);
if(q==NULL)return 0;

memcpy(p,++q,strlen(q)+1);
}
return 0;
}

jorgen


0

Response Number 2
Name: jorgen
Date: August 27, 2003 at 15:54:36 Pacific
Reply:

I made a mistake, the args for delbrackets()
should all be strings, I forgot the '*' on openC and closeC:

The correct version is:

int delbrackets(
char *buf,
char *openC,
char *closeC)



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


differences between Start... Email form for webpage??



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Text technique please help

ASP & Arrays Please Help www.computing.net/answers/programming/asp-amp-arrays-please-help/7208.html

Please help I have starting trouble www.computing.net/answers/programming/please-help-i-have-starting-trouble/5207.html

VB6 Please HELP!!! www.computing.net/answers/programming/vb6-please-help/3119.html