I am using Microsoft Visual C++, and when i try and compile something i either can't or i get " Cannot compile the file in 'C\Program Files\Microsoft Visual Studio\Common\tools\H1.h';
no compile tool is associated with the file extension"
I have placed it in so many different places and each time i get this (but with a different area were it was found but cannot compile)
Also when i do it the way the guide tells me to.
"Let's look at a simple example to understand the elements of a program a little better. Start by creating a new project from the range of alternatives offered on the Projects tab when you click the New... item in the File menu. When the dialog appears, select Win 32 Console Application and name the project Ex1_01; then click on OK." "Next, the Console Application dialog appears. We'll start from the very basic project structure, so choose An empty project, and click on the Finish button. " "The New Project Information tells you about the project you're about to create; it should look something like this:" "The project directory at the foot of the screen may be slightly different on your machine; everything else should be identical. Once your happy with it, click on OK.

We'll start by entering the following program as a new source file, so click the leftmost icon on the standard toolbar, , to create a new text file into which you can type the code." (then code) "Once you have keyed it in, save it as Ex1_01.cpp using the File menu Save As... option. The Save As dialog will offer to save it in the project directory that you just created and, since this file is part of that project, that's the best place for it. Since you have now identified the file by its extension as a file containing C++ code, the keywords in the code will gain their colors. You will be able to see if you have entered Int where you should have entered int, since the two will bedifferent colors" right here is my problem. I do not get channged colors. Can any one help me please. Its really starting to annoy me. I have tried reinstalling it, uninstalling and then installing again, and none of it changes this.
Please help

PS: im relearning since i quit doing C++ some time ago and ican't remember anything (well didn't know much)
But my code gives me 5 errors and i have no idea where they are

#include <iostream.h> 
int divide (int a, int b)
{
    int r;
    r=a/b;
    return (r);
}
    
int main ()
{
int grade, age;
char name[20];
    cout<<"Welcome, what is ur name?: ";
    cin>>name;
    cout<<"you entered: "<<name;
    cout>>"How old are you <<name<< " ?:\n" ;
    cin>>age;
    cout>> "so what grade are you in?: ";
    cin>> grade;
    cout<< "Ok so if i divide ur grade by ur age then I will get" << divide (age,grade) << "right \n";
    return 0;
}

Recommended Answers

All 5 Replies

I always use their wizzard (file/new/...) to create a basic project (like a "Hello World" project) because its easier than trying to start one from scratch.

But have you tried creating a .cpp file rather than .h; generally you compile .c or .cpp files and they include .h files, you don't compile the .h directly.

tight that way works but how would i get the win32 console application one to work?
or once i start a project then i wanna add to it, if i just push new text file it never changes to a C/C++ file

Here's your error:

cout>>"How old are you <<name<< " ?:\n" ;
cout>> "so what grade are you in?: ";

Use << operator for cout and remember to add " at the end of the sentence.

Yeah you push the 'new' button, type in some stuff, and save it as a .h or .cpp. Remember to add it to the project (easy way: right click on text region and select 'add to project').

OR

Use file/new and select source file and it MAKES you give it a file name and I think it adds it to the project for you.

thanks for the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.