Thread: compiler error not formatting output

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    16

    compiler error not formatting output

    Hey all,

    Just have a simple question. I am not much of a programmer, more of a script guy, but I have a client that is getting some weird output with errors while compiling.

    Here is the output he is getting:
    Code:
    g++ test_string.cc -o test_string
    test_string.cc: In function ã: <--- Notice no additional information on error
    test_string.cc:10: error: ã was not declared in this scope <--- Notice no additional information on error
    And should be getting something like:
    Code:
    g++ test_string.cc -o test_string
    test_string.cc: In function main: <---- Information presented
    test_string.cc:10: error: mystringx was not declared in this scope <---- Information presented
    Here is the code he is trying to compile. Keep in mind, this is purposely wrong to show the error output.
    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main(int argC, char* argV[])
    {
    
           string mystring = "Hello World\n";
           cout << mystringx << endl;
    }
    His Lang setting are all correct:
    Code:
    LANG=en_US.UTF-8
    LC_CTYPE="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_PAPER="en_US.UTF-8"
    LC_NAME="en_US.UTF-8"
    LC_ADDRESS="en_US.UTF-8"
    LC_TELEPHONE="en_US.UTF-8"
    LC_MEASUREMENT="en_US.UTF-8"
    LC_IDENTIFICATION="en_US.UTF-8"
    LC_ALL=
    My customer is running RHEL 5.4 64bit.

    Any ideas why this is formatting this way?

    Thanks!
    Joe
    Last edited by Joeg1484; 04-04-2011 at 10:55 AM.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Does he need to set his terminal to use UTF-8 encoding?

  3. #3
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Aside from the obvious text encoding problems, you assigned the string "Hello World\n" to the string variable mystring, and you sent the string mystringx to cout, which doesn't exist.
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

  4. #4
    Registered User
    Join Date
    Dec 2009
    Posts
    16
    Quote Originally Posted by Babkockdood View Post
    Aside from the obvious text encoding problems, you assigned the string "Hello World\n" to the string variable mystring, and you sent the string mystringx to cout, which doesn't exist.
    Yes, I understand that there are errors with the code, but there are deeper issues with the compiler; this is why we wanted to have errors in the code.

    As a refresh:
    This is what the compiler is spitting out (Incorrectly formatted)
    Code:
    g++ test_string.cc -o test_string
    test_string.cc: In function ã: <--- Notice no additional information on error. Missing the `In function main' part.
    test_string.cc:10: error: ã was not declared in this scope <--- Notice no additional information on error. The ã should have been mystringx.
    It should look like this(Correctly formatted):
    Code:
    g++ test_string.cc -o test_string
    test_string.cc: In function main: <---- Information presented
    test_string.cc:10: error: mystringx was not declared in this scope <---- Information presented
    Thanks for the reply!

    Joe
    Last edited by Joeg1484; 04-04-2011 at 03:26 PM.

  5. #5
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Quote Originally Posted by Joeg1484 View Post
    Yes, I understand that there are errors with the code, but there are deeper issues with the compiler; this is why we wanted to have errors in the code.
    Ah yes, how absent-minded of me.
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

  6. #6
    Registered User
    Join Date
    Dec 2009
    Posts
    16
    Quote Originally Posted by Babkockdood View Post
    Ah yes, how absent-minded of me.
    Yes, I read that again and it did seem a bit "Snippy". My apologies for that; it was not my intention to insult anyone!

    Joe

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  2. Output formatting
    By genjiguy in forum C++ Programming
    Replies: 6
    Last Post: 05-19-2005, 03:13 PM
  3. Formatting output
    By BigAl75 in forum C++ Programming
    Replies: 7
    Last Post: 05-12-2004, 07:43 AM
  4. Output formatting
    By Beginner2002 in forum C Programming
    Replies: 3
    Last Post: 09-05-2002, 06:59 PM
  5. formatting output
    By spliff in forum C Programming
    Replies: 2
    Last Post: 08-14-2001, 06:50 PM