"Implicit declaration" warning

Posted by gcc on Stack Overflow See other posts from Stack Overflow or by gcc
Published on 2010-05-19T14:39:17Z Indexed on 2010/05/19 14:50 UTC
Read the original article Hit count: 142

Filed under:
|
|
|

For this code:

int i=0; char **mainp;
for(i=0;i<2;++i)
{
    mainp[i]=malloc(sizeof(char)*200);
    if(!scanf("%[^#],#",mainp[i]))
        break;
   if(i<2)
       scanf("%[^#],#",mainp[i]);
}

GCC emits the warnings:

warning: implicit declaration of function ‘scanf’
warning: incompatible implicit declaration of built-in function ‘scanf’
warning: ‘mainp’ may be used uninitialized in this function

And I get a segmentation fault at runtime

© Stack Overflow or respective owner

Related posts about c

    Related posts about segmentation-fault