C++ Question

By TheJediSlayer ยท 4 replies
Feb 11, 2008
  1. Well, I'm a beginner at C++ and I had a question to ask. It's about the \n and it messing up my code. I'm not sure why but when I tried to compile my program; it wouldn't go and gave me a bunch of errors. After trying to find out the problem, I finally got it, by removing \n in cout<<"Text to output"; it worked. However, I'm a bit confused as to why it worked before and not now. I am still using the same compiler as before, too.

    Tutorials code:

    This was my code:

    Any help would be much appreciated,

  2. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    And what were the "bunch of errors".
    Hint: the error messages from compilers are actually useful and help you to find out what is wrong :p

    Also, what compiler are you using and how did you try to compile your program?

    Assuming that not recognising the escape sequences is some sort of a compiler quirk, use the endl directive for line breaks instead. Something like "cout << "Some text here" << endl;"
  3. TheJediSlayer

    TheJediSlayer TS Rookie Topic Starter Posts: 164

    Well, unfortunately I didn't save any the errors I got, as I was more keen at the time to just trying to fix them; which I did. However, the major error that I came up with, was this error with the \n. Anyways, I'm using Watcom version: open-watcom-f77-win32-1.7a.exe How did I try and compile the program? Well, the way they've shown me how to compile the program. Simply put the code into the text editor, run the .cpp file by pressing the F5 key, and wait and see if it was successful.

    Other information:
    Target Environment: Win32
    Image Type: Character Mode Executable (.exe)
  4. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    Hum.. F77 means the Fortran compiler, not C++.
  5. TheJediSlayer

    TheJediSlayer TS Rookie Topic Starter Posts: 164

    @_@ I've gotten several programs to work though with this compiler. However, you are right. I'm using the wrong compiler. Thank you for your help,

Topic Status:
Not open for further replies.

Similar Topics

Add your comment to this article

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...