Thread: C Programming Compiling Error

  1. #1
    Registered User
    Join Date
    Mar 2019
    Posts
    6

    C Programming Compiling Error

    Hi guys.
    While I'm trying to compile my code, I get a error.
    Thank you for helping.
    C Programming Compiling Error-sss-jpg

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You forgot to specify the type the array elements, e.g.,
    Code:
    int xs[10] = {0, 1, 2};
    notice the int. In your case it would be a const char*

    EDIT:
    Wait, I notice that you have a parameter with the same name. Are you trying to assign to the parameter? If so, this won't work because you cannot assign to an array (but you can initialise an array and can assign to its elements, if they aren't also arrays), and you're trying to use initialisation syntax for assignment.

    I would suggest that either you ditch the parameter, or you initialise the array in the place where you define it (e.g., the caller), or you assign to the individual pointer elements (but note that to avoid mistakes they should be const char* rather than just char* as string constants cannot be modified).
    Last edited by laserlight; 03-25-2019 at 04:26 AM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. lex yacc programming error when compiling both to run together
    By nicolai2k17 in forum Linux Programming
    Replies: 1
    Last Post: 12-25-2016, 03:06 AM
  2. Replies: 2
    Last Post: 02-29-2016, 10:45 AM
  3. Calculator Programming using Tokens not compiling
    By Osman Zakir in forum C++ Programming
    Replies: 8
    Last Post: 04-27-2015, 03:52 PM
  4. Compiling Error
    By Dannibe7 in forum C Programming
    Replies: 1
    Last Post: 09-26-2011, 06:00 PM
  5. Compiling error (Maybe a syntax error)
    By davidvoyage200 in forum C++ Programming
    Replies: 6
    Last Post: 03-27-2003, 10:09 PM

Tags for this Thread