Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Identify the error in this code ?

Identify if I use the typedef statement like the one below , will it produce an error ?

Typedef char str

//And then using it to create a string ,

str fun[80] ;

Or

Typedef char str[80]

str fun ;

Which one is right ?

Should I mention the size of the string in the typedef statement or is ok if I do the way i did above ?

Update:

@roger that was a typing error , auto capitalization by apple. Thank you for your answers , i hope I get marks for it !

2 Answers

Relevance
  • 7 years ago
    Favorite Answer

    Both are right and will compile.

  • roger
    Lv 7
    7 years ago

    neither is correct

    Typedef is an error

    typedef is correct

    if you use typedef instead of Typedef then they both work...

    #include <stdio.h>

    #include <string.h>

    typedef char str[80];

    int main(void)

    {

    str fun ;

    strcpy(fun,"testing");

    printf("%s %d",fun,sizeof fun);

    return 0;

    }

Still have questions? Get your answers by asking now.