how could i have my program cut off the begining of my string?
Ex....
str[]="abcdefg"
?????(str,3/*number of leters to crop*/)
<str="defg">
how could i have my program cut off the begining of my string?
Ex....
str[]="abcdefg"
?????(str,3/*number of leters to crop*/)
<str="defg">
In a perfect world every dog would have a home and every home would have a dog.
Visit My Web Site, Canine Programming
I use Win32 API
i think you can use strcat - look it up in you compiler help
Monday - what a way to spend a seventh of your life
no....my compiler refrence says it appends one string to the end of another
In a perfect world every dog would have a home and every home would have a dog.
Visit My Web Site, Canine Programming
I use Win32 API
try reading the the characters into another string, deleting the original and then copying it in. I know its ineffcient but cant think of another way at the moment
Monday - what a way to spend a seventh of your life
Here's a possible solution:
clu82Code:#include <stdio.h> void CropString(char *p, int amt); int main() { char str[] = "123456789"; CropString(str, 3); printf( "str: %s\n", str ); return 0; } void CropString(char *p, int amt) { char *t; t = p; // used to walk through the string while (*t) // while we are not at the end of the string { if (amt) // skip over characters { amt--; t++; } else // start copying characters { *p = *t; p++; t++; } } *p = '\0'; // finally, add the null }
Well if you want to save some copying, do this
Code:str[]="abcdefg" char *clipped_str = &str[3]; printf( "%s\n", clipped_str );
Thank You so much! It works perfectly now!
In a perfect world every dog would have a home and every home would have a dog.
Visit My Web Site, Canine Programming
I use Win32 API