I need to loose the first 7 characters of a string, but im not sure how. Ive looked through the list of the string.h ones and i cant see anything relevent. Any ideas?
I need to loose the first 7 characters of a string, but im not sure how. Ive looked through the list of the string.h ones and i cant see anything relevent. Any ideas?
pointer arithmetic, search forumns.
Compare
strcpy( dest, src );
with
strcpy( dest, &src[7] );
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
.............................>
............................................take it easy -enjoy-/* he get only 7 caracter or less than 7 */Code:.... char c[7]; gets(c); ....
or
/* the same condition */Code:... char c[7]; scanf("%c",&c); ....
Last edited by enjoy; 05-15-2004 at 01:22 PM. Reason: s
Please stop posting enjoy, you're really not helping anyone at all.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
yea salem, i just came back to post had searched about a bit, and came up with this, but it isnt working at all.
Code:void striphttp(char* link) { char begging[8], temp[100]; char *p; strncpy(begging, link, 7); begging[7] = '\0'; if (strcmp(begging, "http://")) { strcpy(temp, &link[7]); printf("%s\n", temp); strcpy(link, temp); } }
strcmp() returns 0 when the strings are equal
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
doh!