Thread: *ptr = 0 what is the meaning

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    269

    *ptr = 0 what is the meaning

    I'm very new to C and in this project, there's the following...

    Code:
    char *loc = NULL;
    char *tempname = (char *) malloc(sizeof(char) * 255);
    tempname = strdup(name);
    char *oldname = strdup(name);
    int i;
    
    do
    {
    	for (i = 0; i < OPLEN; i++)
    	{
    	//checking operator OP[i]
    	        loc = strchr(oldname, OP[i]);
    		if (loc == NULL)
    			continue;
    		*loc = 0;
    		snprintf(tempname, 255, "%s%s%s", oldname, OP_REP[i], &loc[1]);
    		free(oldname);
    			oldname = strdup(tempname);
    		}
    	}
    while (loc != NULL);
    I'm unsure of the two bolded lines. it seems to me that the 2nd bolded line means "the address of the 2nd element in the dynamic array"..

    but I'm not sure how there can be such a value since we set what the pointer is pointing to to 0
    Last edited by dayalsoap; 09-17-2010 at 10:59 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HELP!what is the meaning of "&" ???
    By zxlew in forum C Programming
    Replies: 2
    Last Post: 01-18-2009, 03:29 AM
  2. the meaning of " >> "
    By arian in forum C++ Programming
    Replies: 8
    Last Post: 03-30-2005, 10:40 AM
  3. The Meaning of Life: A Trick Question?
    By chix/w/guns in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 07-12-2004, 07:53 PM
  4. Replies: 8
    Last Post: 04-11-2003, 07:37 AM
  5. would you help me with Linked list, please?
    By unhwan in forum C Programming
    Replies: 1
    Last Post: 06-11-2002, 12:24 AM