English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i am encountering 2 errors upon building when using the following code

#include
#include "stdafx.h"
int main()
{
cout<<"*"< cout<<"**"< cout<<"***"< cout<<"****"< cout<<"*****"< cout<<"****"< cout<<"***"< cout<<"**"< cout<<"*"< return 0;
}


any ideas what i am doing wrong? i am getting these errors
error C2065: 'endl' : undeclared identifier and
error C2065: 'cout' : undeclared identifier


is there a special thing i need to "#include" ? apparently, using namespace std; is useless with C++Express 2005. i dunno?

2007-03-12 13:59:56 · 7 answers · asked by eyefixguitars 1 in Computers & Internet Programming & Design

in the version i am using, it will not allow using namespace std;


also, it gave me t stdafx.h when i started my new file. when i modified it, it gave MOREE errors than i had to begin with

2007-03-12 18:16:38 · update #1

7 answers

one of two things:

1 change the line #include to
#include or #include "iostream.h"

2 use #include "stdio.h" or #include

2007-03-13 02:12:10 · answer #1 · answered by justme 7 · 0 0

does it say what line the error is on?

what are you trying to do? output all those stars? thats easy.

but idk abotu stdafx.h ive never used that portion of your code.

and personally i prefer not to use the "<
#include
using namespace std;
int main(){

cout<<"*\n";
cout<<"**\n";
cout<<"***\n";
cout<<"****\n";
cout<<"*****\n";
cout<<"****\n";
cout<<"***\n";
cout<<"**\n";
cout<<"*\n";
return 0;
}

i dont think your copying and pasting your code correctly because if it says cout isnt a declared identifier your either missing a ; at the end of one of your lines, or your missing a "" or you may have accidently typed cout>> instead of cout<< or you may have only 1 < instead of 2.

that should cover all your mistakes.

2007-03-12 21:13:44 · answer #2 · answered by dbreda 2 · 0 0

Looks good to me. Just a guess... there doesn't appear to be a space between the #include and the

2007-03-12 21:05:16 · answer #3 · answered by BigRez 6 · 0 0

an indeclared identifier is an undeclared variable you have no variable declarations
in regular C++ code this would be written as follows
#using
using namespace System;
int main()
{
//declare variables
CODE GOES HERE FOR VARIABLES example below
double exNum1=0.0;
double exNum2=0.0;
double exTotal =0.0;

// get input
Code Goes Here again example below
Console::Write("Get num 1: ");
exNum1= Convert::ToDouble(Console::ReadLine());
etc.

//do some sort of processing
CODE GOES HERE example below
exTotal = exNum1 + exNum2;

// display result
Code goes here example below

Console::Write("The Total is {0}: exTotal.ToString());

//end main
return 0;
}

2007-03-12 21:53:53 · answer #4 · answered by girliegeek2000 2 · 0 1

i think you forgot to put a namespace declaration.
using namespace std;

also, you might have to include , some manipulators for iostreams need it.

2007-03-12 23:27:16 · answer #5 · answered by mirbeksm 2 · 0 1

declare the var?

ie: endl = 0 ?

2007-03-12 21:02:33 · answer #6 · answered by Funky G 5 · 0 1

#include "stdafx.h"

should be

#include

and you need to include the windows.h or win.h, somthing like that.

2007-03-15 10:23:28 · answer #7 · answered by Stocky 2 · 0 0

fedest.com, questions and answers