473,322 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

"cout undeclared identifier"

I am using visual studio and can't seem to figure out why I keep getting this error when I compile. Any suggestions? Here is the relevant code:
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. int main()
  3. {
  4. .......
  5.     //reassign arrays
  6.     for (int l = 0; l <= 49; l++)
  7.         n [l] = nplus1 [l];
  8.         //output
  9.         if (t == .1 || t == .25 || t == .5 || t == 1 || t == 2)
  10.         {
  11.             cout<< "t = " << t << "/n";
  12.             cout<< "y values " << yvalue << "/n";
  13.             cout<< "velocity " << n << "/n";
  14.         }
  15. }
Apr 23 '07 #1
5 19423
sicarie
4,677 Expert Mod 4TB
I am using visual studio and can't seem to figure out why I keep getting this error when I compile. Any suggestions? Here is the relevant code:
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. int main()
  3. {
  4. .......
  5.     //reassign arrays
  6.     for (int l = 0; l <= 49; l++)
  7.         n [l] = nplus1 [l];
  8.         //output
  9.         if (t == .1 || t == .25 || t == .5 || t == 1 || t == 2)
  10.         {
  11.             cout<< "t = " << t << "/n";
  12.             cout<< "y values " << yvalue << "/n";
  13.             cout<< "velocity " << n << "/n";
  14.         }
  15. }
I see two things right off - you don't have braces ( { and } ) with your 'for' loop, and I'm not sure if the precedence on the '||'s will make them complete before the '=='s, you might consider putting the t == var in parentheses, though as I said, precedence on those might work out (I can't remember off the top of my head).

What error are you getting?
Apr 23 '07 #2
I see two things right off - you don't have braces ( { and } ) with your 'for' loop, and I'm not sure if the precedence on the '||'s will make them complete before the '=='s, you might consider putting the t == var in parentheses, though as I said, precedence on those might work out (I can't remember off the top of my head).

What error are you getting?
"cout undeclared identifer"
It isn't recognizing cout as a function.
It's been a few years since my C++ class!
Apr 23 '07 #3
sicarie
4,677 Expert Mod 4TB
"cout undeclared identifer"
It isn't recognizing cout as a function.
It's been a few years since my C++ class!
If that's directly copied and pasted, try putting spaces between the cout and the '<<' chars. Maybe be sure to include 'using namespace std;' under your includes.

I'm actually kind of surprised that your compiler wasn't complaining about the lack of braces after your for loop.
Apr 23 '07 #4
AdrianH
1,251 Expert 1GB
I think you guys need a lot more coffee or just some sleep. ;) The std namespace wasn't imported. Either put using namespace std; after the #include <iostream> or you must explictly state what package the cout is in, i.e. std::cout.

The lack of braces will not cause an error or warning as that is legal C/C++ syntax. It just means that you will be looping over the n [l] = nplus1 [l]; as the body of the loop.

Going to take my power nap now. :D


Adrian
Apr 23 '07 #5
JosAH
11,448 Expert 8TB
The std namespace wasn't imported.
See reply #4:
Maybe be sure to include 'using namespace std;' under your includes.
kind regards,

Jos
Apr 23 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Ensoul Chee | last post by:
I used #include <iostream.h> int m; cout << "Hexadecimal == 0x" << hex << m << endl; to print value of m in hexadecimal mode. But I got the compile error like this couttest.cpp:20 `hex'...
2
by: Jason Sauer | last post by:
We use "FOR XML EXPLICIT" and "OPENXML" heavily on our SQL 2000 Advanced server. Every now and then we get an "Undeclared Tag ID" error (SQL Error #6806). If I open the stored procedure, modify it...
6
by: craigbeanhead | last post by:
Hi, I'm teaching myself C from K&R2. I've come across something that I really don't understand. When I try to compile the following code (in VC++7), I get an "undeclared identifier" error. When...
6
by: thistleryver | last post by:
I thought it meant that I hadn't declared a variable but I have. int DoubleNumbers(int seq, int *digitNum) { int i, j; for (i = 0; i = 9; i++) for (j = i + 1; j = 9; j++) if (seq...
23
by: mahesh | last post by:
Hi all, I have following code that is supposed to increase the power by specified value. int main() { system("cls"); int i, exponent; double base; double new_base=0.0;
1
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
2
by: Scofield | last post by:
copy (coll.begin(), coll.end(), ostream_iterator<int>(cout, " ")); when compile, it yields the following errors: list1.cpp:12: error: ¡®ostream_iterator¡¯ was not declared in this scope...
3
by: rdsandy | last post by:
Hi, I am using SQL Server 2005. I have this stored procedure below but it doesn't work. It is for an archiving process I am currently implementing. The RiskArchive table has fields ArchiveID...
2
by: thomas | last post by:
#include<iostream> #include<vector> #include<map> #include<set> #include<iterator> #include<string> #include<algorithm> using namespace std;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.