typedef char[25] mystring; //?

This is a discussion on typedef char[25] mystring; //? within the C++ Programming forums, part of the General Programming Boards category; ok, I'm working on this list class, and I'm supposed to convert it to run cstrings instead of ints, but ...

  1. #1
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179

    typedef char[25] mystring; //?

    ok, I'm working on this list class, and I'm supposed to convert it to run cstrings instead of ints, but I've hit trouble at the very beginning. I was using this: (so that I could change the datatype easily, har har)
    Code:
    typedef int ItemType;
    so I changed it to this:
    Code:
    typedef char[25] StringType;
    but when I try that I get weird errors:
    c:\program files\microsoft visual studio\myprojects\lab\datadefn.h(1) : warning C4091: 'typedef ' : ignored on left of 'char' when no variable is declared
    c:\program files\microsoft visual studio\myprojects\lab\datadefn.h(1) : error C2143: syntax error : missing ';' before '['
    c:\program files\microsoft visual studio\myprojects\lab\datadefn.h(1) : error C2143: syntax error : missing ';' before '['
    It worked fine the other way, does anybody know what's going on?
    Illusion and reality become impartiality and confidence.

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Yeah,

    'typedef ' : ignored on left of 'char' when no variable is declared

    Apparently, you can't typdef an anonymous char array.

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    typedef char StringType[25];

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    In golfinguy4's example, StringType becomes the synonym for a char[25] array.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 11:36 AM
  3. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 08:22 AM
  4. build errors migrated from dx9b to dx9c sdk
    By reanimated in forum Game Programming
    Replies: 4
    Last Post: 12-17-2004, 06:35 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 11:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21