Page 1 of 1

Posted: Thu Mar 27, 2008 12:38 am
by ray.wurlod
Begin by identifying the complete set of "special characters". Then use a Convert() function to replace them with a zero-length string.

Posted: Thu Mar 27, 2008 3:15 am
by uppalapati2003
those special charecters are not constent our sorce as files because of that i am getting different type of non keyboard special charecters.
only one thing i have to do other than A to Z and 0 to 9 remaining charecters i need to remove from the string .
how to do that please guide me.

Posted: Thu Mar 27, 2008 4:56 am
by BugFree
This is a parallel routine that i wrote. And meets your requirement.

Code: Select all

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char* DeleteChars(char *inputstring)
{

	char *OutPut= (char *)malloc (sizeof(char *));

	int length = 0;

	int StringLength = strlen(inputstring);

	if (length == 0)
		OutPut[length] = '\0';
	else
	{
		while(*inputstring)
        	{
			if ((*inputstring>= 32) && (*inputstring<= 126))
                	{
				OutPut[length] = *inputstring;

				length++;
			}
			inputstring++;
		}
		OutPut[length] = '\0';
	}


return OutPut;

free(OutPut);

}
Hope this helps.

Posted: Thu Mar 27, 2008 5:50 am
by ray.wurlod
Just curious; where does the variable called "i" get its value? You test it in

Code: Select all

(i == 0) 

Posted: Thu Mar 27, 2008 5:53 am
by BugFree
ray.wurlod wrote:Just curious; where does the variable called "i" get its value? You test it in

Code: Select all

(i == 0) 
...
:oops: :oops:

Copy paste error. I changed it in the post. Tested it and it is working.

Posted: Thu Mar 27, 2008 8:19 am
by DSguru2B
I remember building something like this a while back. Check the following post for reference.
viewtopic.php?t=108011&postdays=0&posto ... g&start=15
Bugfree, get rid of free(OutPut); from you code as it will never be executed. The engine will take care of freeing the memory.

Posted: Thu Mar 27, 2008 11:41 pm
by BugFree
:) I have read somewhere in the forum that the memory has to be explicitly handled in the parallel routine. so the free(OutPut). I dint know that the parallel engine will take care of the memory clean up.

Posted: Fri Mar 28, 2008 8:20 am
by DSguru2B
It is true that memory management needs to be handled but no statements after a "Return" statement gets executed, hence the request to get rid of it.