Why do i get segfault at the end of the application after everything's been done properly ?

Posted by VaioIsBorn on Stack Overflow See other posts from Stack Overflow or by VaioIsBorn
Published on 2010-04-02T11:32:51Z Indexed on 2010/04/02 11:53 UTC
Read the original article Hit count: 224

Filed under:
|
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
        unsigned char *stole;
        unsigned char pass[] = "m4ak47";
        printf("Vnesi password: \t");
        scanf("%s", stole);
        if(strncmp(stole, pass, sizeof(pass)) != 0)
        {
                printf("wrong password!\n");
                exit(0);
        }
        else
                printf("Password correct\n");
        printf("some stuf here...\n\n");
        return 0;
}

This program is working nice, but with one problem - if the password is correct then it DOES do the printing of 'some stuf here...' but it also shows me segmentation fault error at the end. Why ?

© Stack Overflow or respective owner

Related posts about c

    Related posts about segmentation-fault