I am trying to read a text file containing the string "a3rm5t?7!z\*&gzt9v" and put all the numeric characters into a character string to later convert into an integer. 

I am currently trying to do this by using sscanf on the buffer after reading the file, and then using sprintf to save all characters found using %u in a character string called str. 

However, the integer that is returning when I call printf on str is different each time I run the program. What am I doing right and what am I doing wrong? 

This code works when the text file contains a string like "23dog" and returns 23 but not when the string is something like 23dog2.

EDIT: I now realize that i should be putting the numeric characters in a character ARRAY rather than just one string.

```
int main(int argc, const char **argv)
{
    int in;
    char buffer[128];
    char *str;
    FILE *input;

    in = open(argv[1], O_RDONLY);
    read(in, buffer, 128);

    unsigned x;
    sscanf(buffer, "%u", &x);
    sprintf(str,"%u\n", x);
    printf("%s\n",str);

    close (in);

    exit(0);
}

```