can u tell me the problem

Discussion in 'C' started by ismitevijay, Aug 26, 2006.

Thread Status:
Not open for further replies.
  1. ismitevijay

    ismitevijay New Member

    Joined:
    Aug 26, 2006
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    can anyone tell me where the err is :'

    #include<stdio.h>
    void set(char *items[]);

    int main()
    {
    char *items[]={"apple","pear","banana","grape"};
    set (items);
    return 0;

    }

    void set(char *items[])
    {
    printf ("\t%s\n", items[2]);
    }

    this prog compiles without segmentation fault; and gives "banana " as o/p.

    but when i giv
    #include<stdio.h>
    void set(char *items[]);

    int main()
    {
    char *items[10];
    gets(items[2]);

    set (items);
    return 0;

    }

    void set(char *items[])
    {
    printf ("\t%s\n", items[2]);
    }

    but when i try to gets the names : i get segementation fault;
    plz help
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,336
    Likes Received:
    377
    Trophy Points:
    83
    Duplicate of [thread=1264]CAN U TEll me the problem[/thread]. Thread closed.
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice