Loosing first 7 characters of a string

This is a discussion on Loosing first 7 characters of a string within the C Programming forums, part of the General Programming Boards category; I need to loose the first 7 characters of a string, but im not sure how. Ive looked through the ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    114

    Loosing first 7 characters of a string

    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?

  2. #2
    Ultraviolence Connoisseur
    Join Date
    Mar 2004
    Posts
    472
    pointer arithmetic, search forumns.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159

    Lightbulb s

    .............................>

    Code:
    ....
    char c[7];
    gets(c);
    ....
    /* he get only 7 caracter or less than 7 */
    or
    Code:
    ...
    char c[7];
    scanf("%c",&c);
    ....
    /* the same condition */
    ............................................take it easy -enjoy-
    Last edited by enjoy; 05-15-2004 at 01:22 PM. Reason: s

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    May 2004
    Posts
    114
    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);
    	}
    }

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Registered User
    Join Date
    May 2004
    Posts
    114
    doh!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  2. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 01:02 AM
  3. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  4. can anyone see anything wrong with this code
    By occ0708 in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 11:47 AM
  5. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 09:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21