Few questions

This is a discussion on Few questions within the C++ Programming forums, part of the General Programming Boards category; Im all new to the world of programming.. I just started learning C++ yesterday and i have Visual Studio 2010. ...

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    8

    Few questions

    Im all new to the world of programming.. I just started learning C++ yesterday and i have Visual Studio 2010. First off, how do i test my codes? And i have a few simple codes for you cuz i just want to make sure i have the right technique and doing it right.

    PS these are just so i can get the concept. Simple tasks were made a little more complicates so i can get down variables, and other things.


    Variables and arithmatic:
    Code:
    #include <iostream>
    using namespace std;
    
    int var1 = 45;
    
    int main()
    {
    	cout << "Value of variable 1:     " << var1 << endl;
    	int sum = var1 + 7;
    	cout << "Value of variable 1 plus 7:     " << sum << endl;
    	return 0;
    }

    Hello World:
    Code:
    #include <iostream>
    using namespace std ;
    
    void message(), secondmessage(), thirdmessage();
    
    int main()
    {
    	cout << "Hello World" << endl;
    	message();
    	cout << "Made by FuRy" << endl;
    	secondmessage();
    	thirdmessage();
    	return 0;
    }
    
    void message()
    {
    	cout << "This is a simple program..." << endl;
    }
    
    void secdondmessage()
    {
    	cout << "This program can now terminate" << endl;
    }
    
    void thirdmessage()
    {
    	cout << "If i got the code right... xP" << endl;
    }

  2. #2
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,761
    Have you tried compiling?

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    Wheres the button to compile? Theres like a billion buttons all over the screen. And dont i hav to have a header file and other files to compile? I just clicked make now cpp file

  4. #4
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    917
    Any IDE has a project concept. Use the wizard to make a "c++" or "basic" or whatever console application. Pick new->project or the like. I don't know I use 2008. Then fill in the options you want in the wizard. "There are a million buttons" is a lame excuse. Google how to compile in visual studio.

    Edit: It's called "building" for a project (compile+link).
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  5. #5
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    Quote Originally Posted by CodeMonkey View Post
    "There are a million buttons" is a lame excuse.
    Well sorry. This is my first time using Visual Studio. Im barely 14 and not the sharpest crayon in the box. Im not as smart as any of you here. I came here to try to learn how to use C++.

    Ok sorry bout that, I got a lil mad... Everyones a genious here and its expected that you know how to compile and write in C, C++, C# or even all three. I just dont want to get looked down upon because im younger, not as smart, and new to this stuff.

    Have a nice day.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,001
    But honestly FuRy, if you use a new application, you can always search for some tutorials on google. Or even something like "how to compile with visual studio".
    There should be plenty of hits. You don't have to learn the IDE over night.
    As to your question, once you have a project, goto build -> build solution (or press Ctrl+shift+B or F7 depending on what keyboard configuration you have).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    Quote Originally Posted by Elysia View Post
    But honestly FuRy, if you use a new application, you can always search for some tutorials on google. Or even something like "how to compile with visual studio".
    Ok i did that. I found a way to compile in the Visual Studio CMD. Though it doesnt work.
    This is what happened.

    Code:
    C:\Program Files\Microsoft Visual Studio 10.0\VC>dir HelloWorld*
    Volume in drive C is OS
    Volume serial number is *CENSORED*
    
    Directory of C:\Program Files\Microsoft Visual Studio 10.0\VC
    
    7/26/2010   9:28 AM     478 HelloWorld.cpp
                      1 file(s)     478 bytes
                     0 Dir(s)     69,233,328,128 bytes free
    
    C:\Program Files\Microsoft Visual Studio 10.0\VC>cl /EHsc HelloWorld.cpp
    *COPYRIGHT INFORMATION*
    
    HelloWorld.cpp
    C:\Program Files\Microsoft Visual Studio 10.0\VC\HelloWorld.cpp : fatal error C1083: Cannot open compiler generated file: 'HelloWorld.obj': Denied

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,001
    UAC is enabled? Proper write permissions for the program files directory?
    Besides, you shouldn't be putting your source files in the IDE directory. You should be putting it in a user directory, such as my documents\visual studio 2010\projects or something (which is default).
    It sounds like you haven't created a project either.

    So a short tutorial:
    File -> New -> Project.
    Select "(Win32) Console Application".
    Enter project name.
    Accept default and click finish.
    Put your code inside YourNameOfTheProject.cpp.
    Goto Build -> Build solution to compile.
    Goto Debug -> Start with (or without) debugging to run your program.
    Last edited by Elysia; 07-29-2010 at 09:40 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    Quote Originally Posted by Elysia View Post
    UAC is enabled? Proper write permissions for the program files directory?
    Besides, you shouldn't be putting your source files in the IDE directory. You should be putting it in a user directory, such as my documents\visual studio 2010\projects or something (which is default).
    It sounds like you haven't created a project either.

    So a short tutorial:
    File -> New -> Project.
    Select "(Win32) Console Application".
    Enter project name.
    Accept default and click finish.
    Put your code inside YourNameOfTheProject.cpp.
    Goto Build -> Build solution to compile.
    Goto Debug -> Start with (or without) debugging to run your program.
    Well how i did it was what i found on the Microsoft site on how to compile. And their method said to put it in the VC folder and use the CMD to compile.

    Oh and apparently my entire C drive is "read only" and whenever i edit properties and uncheck read only and click apply, it says "Applying properties" and takes 1-2 hours to complete. When im done it says "Success" and i go to properties and find its read only again... Ive tried to un-read only (im not sure thats even a word) it about 6 times. Its not a virus ive scanned with Kaspersky, MBAM, ComboFix and a whole artillery of antivirus/malware software.

    Any info on tht? Its really annoying me...
    And thanks for the tut ^_^

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,001
    It's permission problems, not read only problems.
    Properties -> security tab, if you have it.
    But that's not really the issue. You shouldn't be messing with that. Instead do like I said. Move the source to a private folder such as my documents or whatever you wish to call it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Quote Originally Posted by Elysia View Post
    So a short tutorial:
    File -> New -> Project.
    Select "(Win32) Console Application".
    Enter project name.
    Accept default and click finish.
    Put your code inside YourNameOfTheProject.cpp.
    Note that YourNameOfTheProject.cpp as generated by VS using these steps will start with the line
    #include "stdafx.h"

    Do not remove, change, or move this line!
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  12. #12
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    Quote Originally Posted by CornedBee View Post
    Do not remove, change, or move this line!
    Just saying that makes me want to see what happens if it gets removed...
    And right after that line do i include the lines
    Code:
    #include <iostream>
    using namespace std;

  13. #13
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    In beginner examples, that's very often how it continues.

    Feel free to remove the line and see what happens. Just remember it so that you can add it back.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  14. #14
    Your imaginary friend
    Join Date
    Jan 2010
    Location
    Canada
    Posts
    76
    Don't worry FuRy, I'm also a noobie, and also 14!

  15. #15
    Registered User
    Join Date
    Jul 2010
    Posts
    8
    Quote Originally Posted by jerimo View Post
    Don't worry FuRy, I'm also a noobie, and also 14!
    Yay im not alone!

    Quote Originally Posted by CornedBee View Post
    In beginner examples, that's very often how it continues..
    Oh i thought that rule always applied... So theres more things to use at the top???

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. malloc problem
    By Tool in forum C Programming
    Replies: 23
    Last Post: 03-12-2010, 10:54 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 06:36 AM
  3. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 08:42 AM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 08:22 AM

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