Like Tree1Likes
  • 1 Post By linucksrox

C++ Variables - Tutorial example not working

This is a discussion on C++ Variables - Tutorial example not working within the C++ Programming forums, part of the General Programming Boards category; Hello, In the c++ tutorial there is a section on variables just after the first hello world program. Using dev ...

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    3

    Unhappy C++ Variables - Tutorial example not working

    Hello,

    In the c++ tutorial there is a section on variables just after the first hello world program.

    Using dev cc i have entered and compiled the example code that is included in the tute, but when i try to run it nothing happens.

    What should i do?

    I have made sure i have entered the code exactly as written, and the previous example codes worked fine...
    The code is as follows:
    Code:
    #include <iostream> using namespace std; int main() { int thisisanumber; cout<<"Please enter a number: "; cin>> thisisanumber; cin.ignore(); cout<<"You entered: "<< thisisanumber <<"\n"; cin.get(); }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,144
    What do you mean by "nothing happens"?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    3
    Exactly that... nothing. I compile the program, save it, and try to run it but nothing at all changes or happens. No program window. no discernable event of any kind. The window just stays the same.

    But when I try to run the "hello world" program using the same tools all works fine. I'm really confused...

  4. #4
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    Did you try "Compile and run"? You can just press F9. I tried compiling this on my machine with the latest version of Dev-C++, but got a message from AVG stating that this contained a trojan. Maybe your antivirus is blocking it behind the scenes.
    Can anyone else find anything malicious about this code? I changed "\n" to endl and it ran just fine without any intervention from AVG.
    Last edited by linucksrox; 02-26-2012 at 10:31 PM.
    laserlight likes this.
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,144
    Quote Originally Posted by linucksrox
    I tried compiling this on my machine with the latest version of Dev-C++, but got a message from AVG stating that this contained a trojan. Maybe your antivirus is blocking it behind the scenes.
    Can anyone else find anything malicious about this code? I changed "\n" to endl and it ran just fine without any intervention from AVG.
    It is clearly a false positive from AVG.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    Right, but I wonder what AVG is seeing as suspicious behavior. Regardless, I compiled using Codeblocks and it worked without any issues. I'd recommend uninstalling Dev-C++ and updating to Codeblocks since it's more up to date.
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  7. #7
    Registered User
    Join Date
    Feb 2012
    Posts
    3
    Thanks guys you were right. I turned avg off through the task manager and the program immediately ran. I wonder what causes this? Do you think it will be a common problem? Should i switch to a different compiler before continuing the tutorial? You mentioned codeblocks, is that the best to use?

  8. #8
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,504
    Quote Originally Posted by muttley View Post
    Thanks guys you were right. I turned avg off through the task manager and the program immediately ran. I wonder what causes this? Do you think it will be a common problem? Should i switch to a different compiler before continuing the tutorial? You mentioned codeblocks, is that the best to use?
    Code::Blocks is an IDE, the compiler is up to you( mingw is generally used)
    You can try by configuring your antivirus properly..as to trust the compiler.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  9. #9
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    Also I'd recommend setting AVG to alert you when it finds threats, so you know when it's blocking a program.
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 17
    Last Post: 09-15-2011, 12:56 PM
  2. Sockets tutorial, datagram sockets example not working for me
    By caesius in forum Networking/Device Communication
    Replies: 14
    Last Post: 12-26-2009, 03:40 PM
  3. Replies: 6
    Last Post: 12-02-2009, 08:47 AM
  4. Working with variable variables
    By Differentialpi in forum C Programming
    Replies: 1
    Last Post: 01-06-2008, 10:35 PM
  5. Winprog BMP tutorial not working
    By Brigs76 in forum C++ Programming
    Replies: 2
    Last Post: 04-18-2005, 08:36 PM

Tags for this Thread


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