Thread: problem printing string

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    77

    problem printing string

    hello to all,

    I am having problems printing a string in reverse using the reverse function.

    here is my code:

    Code:
    char topSequence[] = reverse(rowAlign) ;
    char bottomSequence[] = reverse(colAlign) ;
    I am receiving the following error:

    error: invalid initializer

    I do not believe the problem is with the rowAlign and colAlign variables. Everything is compiling fine until this point.

    Any suggestions on how to fix?

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Carnac the Magnificent could not figure this out with what little code you have posted.
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    77
    These are the lines of code that are being singled out by the compiler. There are no other errors being reported by the compiler.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    I don't think you can initialize an array like that.

    Try using char *s

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    array initializers should be constant strings as far as I remember...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. string problem
    By INeedSleep in forum C++ Programming
    Replies: 24
    Last Post: 11-08-2007, 11:52 PM
  3. convert double to string problem
    By gandalf_bar in forum C++ Programming
    Replies: 6
    Last Post: 03-15-2004, 05:14 AM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM