In a part of the program I'm working on I assign a name differently in different circumstances, but I want to keep the name either way, obviously. So I did something like so:

```
char *name;
if(*condition one*){
    char namebuilder[30] = "";
    //fill char array here
    name = namebuilder;
} else {
    name = info->name; //a char* from a struct
}

char otherstring[30] = "______________________________"

```

So basically the problem I'm having is that when the function takes the `else` route name sticks around and works just fine. But when it makes namebuilder and constructs the name, for some reason `otherstring` is ending up in the same address as name, and the name is getting overwritten with "**\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_**". I don't understand why this is happening or how I can prevent it. 

P.S: I've tested it by printing the addresses of name and otherstring, and they have the same address stored in them, but only if namebuilder was used.

Extra Background: this is a little program I'm making to mess around with pthreads, so it could possibly have to do with threading I guess, but none of the variables I mentioned are global.

EDIT: Here's the actual code for those of you asking.
 struct thread\_data
 {
 char \*name;
 int max;
 };

```
void* race(void* params)
{
    struct thread_data* info;
    info = (struct thread_data*)params;
    int len = strlen(info->name);
    char* name;
    if(info->max > len){
        int i;
        char newname[30] = "";
        for(i = 0; i < info->max-1; i++){
            if(i < len){
                newname[i] = info->name[i];
            } else {
                char nextchar = randChar();
                newname[i] = nextchar;    
            }
        }
        newname[info->max] = '\0';
        name = newname;
    } else {
        name = info->name;
    }
    pthread_mutex_lock(&locker);
    printf(name); //This correctly prints the name either way.
    printf(" takes off!\n");
    pthread_mutex_unlock(&locker);
    //begin trying to spell here.
    int spelt = 0;
    char spelling[30] = "______________________________";
    // All code after this sees name as "______________________________" only if it came  
    // from the if statement and not the else.

```