This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Strings.....


Hello to everyone....

I need a really fast way to do the following:

I have a (char *) that contains am arbitrary string and have space to do
the desired operation. Now i need to left-shift the string from n
positions and fill the initial n position with space.
for example:

char *string;

string = (char *)malloc(sizeof(char)*10);
string = "Hello\0";
left_shift_string(string,2);
printf("String value:%s\n",string);

When you execute the following code, will be printed:

"String value:  Hello"

Note that now we have two spaces at the beggining of the string.

The function can assume that we HAVE space to do the operation, n
will be an positive integer, must run on Windows/Dos/Unix/Linux
systems and must follow the prototype:

char *left_shift_string(char *string,int n);

Thanks....
[]'s

-- 
Nelson Guedes Paulo Junior   
E-mail:  <npaulo@linux.ime.usp.br>   UIN: 2489382 (Tender AML)
HomePage: (Em eterna construção)
http://members.xoom.com/DuneKiller/index2.html

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]