Thread: Tutorial any good?

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    9

    Tutorial any good?

    I was looking around for a good tutorial and was wondering if the one on the site was any good??

  2. #2
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    They're good if you can learn from them...and I think http://www.cprogramming.com/tutorial.html has some pretty good ones. But what do you want a tutorial on? Are you just learning? If so this site is a great one. Be more specific
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    9
    Basically all I have done is some visual basic, html, and asp. I really really want to learn C++ but I need a push in the right direction.

    I downloaded bloodshed compiler and was trying to some simple things with getting input from the use slapping it into a variable then outputting that to the screen.

    What am I doing wrong? Please don't slam me I am totally winging this:

    1. I create a new "Source file"
    2. type in my code then I should be able to compile and run it no??

    thanks

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    1. I create a new "Source file"
    2. type in my code then I should be able to compile and run it no??
    Yes, you should. But what problems are you having? With your compiler, IDE or your source code?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Registered User
    Join Date
    Oct 2002
    Posts
    9
    Well here it goes....this is my code

    Code:
    #include
    
    int main()
    
    {
    
    int varNumber; //variable to place number in??
    
    cout<<"Please enter any number";  //get input from user??
    
    cin>>varNumber; //place input from user into the varible??
    
    cout<<"varNumber";  //out the value of the variable to the screen??
    
    return 0;
    
    }
    and this is the error I get back from the bloodshed compiler

    1 C:\Dev-C++\mingw32\include\test.cpp
    `#include' expects "FILENAME" or <FILENAME>

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by Anthony172
    Well here it goes....this is my code

    Code:
    #include
    
    int main()
    
    {
    
    int varNumber; //variable to place number in??
    
    cout<<"Please enter any number";  //get input from user??
    
    cin>>varNumber; //place input from user into the varible??
    
    cout<<"varNumber";  //out the value of the variable to the screen??
    
    return 0;
    
    }
    and this is the error I get back from the bloodshed compiler
    You need to have

    #include <iostream.h>

    OR

    #include <iostream>
    using namespace std;

    The second method is preffered but I don't know if Dev-C++ supports it or not.

  7. #7
    Registered User
    Join Date
    Oct 2002
    Posts
    9
    Thank you very much!

  8. #8
    Registered User
    Join Date
    Oct 2002
    Posts
    9
    It runs now but I cannot get program to spit back the numer I type in. As soon as I type the number the window disappears. I know I am doing something wrong because the program itself is compiling fine.

    Code:
    #include <iostream.h>
    
    int main()
    
    {
    
    int varNumber; //variable to place number in??
    
    cout<<"Please enter any number:  ";  //get input from user??
    
    cin>>varNumber;  //place input from user into the varible??
    
    cout<<"This is the number you typed in:  "<< varNumber;  //out the value of the variable to the screen??
    
    return 0;
    
    }

  9. #9
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Check out the programming FAQ on pausing your program, and then pause it at the end of your program. Your program is working fine; if you run your program from the prompt, then you'll see that it is.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  10. #10
    Registered User
    Join Date
    Jun 2002
    Posts
    82
    See http://www.cprogramming.com/boardfaq.html#pause

    Summarized: put a getch() command at the end of your program, and put '#include <conio.h>' at the beginning of your program. What is happening is, your program opens up the console window for input & output, but as soon as your number is output to the screen the program is complete and it no longer needs to keep the console window open. So you need to make the program wait for input from you before it finishes execution.

    Personally I tend to use a 'string s; cin >> s' command to get the same results, but it requires the user to press enter and requires an additional variable to take the input from the stream. Someone who knows the iostream library better than I may be able to say whether cin has something equivalent to getch(). This would have the advantage of minimizing the #included files, which I believe will cut down on the size of the executable file.
    Claus Hetzer
    Compiler: Borland 5.5 (on Windows)
    Solaris CC (on Unix)
    Known Languages: C++, MATLAB, Perl, Java

  11. #11
    Registered User
    Join Date
    Oct 2002
    Posts
    9
    Thanks guys it worked. I know it's really elementary but it helps me out alot. Thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Do you have to be good at math to be good at C/C++?
    By orion- in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 01-07-2007, 05:15 AM
  2. In a game Engine...
    By Shamino in forum Game Programming
    Replies: 28
    Last Post: 02-19-2006, 11:30 AM
  3. A good linked list tutorial, and some other tuts
    By frenchfry164 in forum C++ Programming
    Replies: 1
    Last Post: 11-20-2002, 09:58 PM
  4. Good OpenGL tutorial
    By Yoshi in forum C++ Programming
    Replies: 3
    Last Post: 11-12-2002, 07:20 PM
  5. Is there a good tutorial for Windows programming??
    By BubbleMan in forum Windows Programming
    Replies: 3
    Last Post: 08-16-2001, 03:49 PM