Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Can't use "Cout" with For.


  • Please log in to reply
3 replies to this topic

#1 bigalexe

bigalexe

  • Members
  • 170 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Michigan, USA
  • Local time:11:32 PM

Posted 01 October 2011 - 10:37 AM

Ok problem is apparently simple... IDE and compiler are Visual Studio 2010.

The following code works:

//start
for (int xi=0; xi<=ARRAY_SIZE; xi++)
{
cin >> MyArray[xi]; //inputting array values now.
}
//end

This changed code does not and says Cout is ambiguous.

//start
for (int xi=0; xi<=ARRAY_SIZE; xi++)
{
cin >> MyArray[xi]; //inputting array values now.
cout << "ERROR... PLEASE GO AWAY";
}
//end

Seriously there's not even any variables in the cout... why doesn't cout want to come play?
AMD Phenom II X6 2.8ghz
8GB DDR3 RAM
XFX ATI Radeon HD6850 1 GB DDR5, 26" Widescreen HDMI
500GB + 80GB HDD
Windows 7 Pro, Mozilla Firefox, AutoCAD 2011, Solidworks 2009
1/19/2012

BC AdBot (Login to Remove)

 


#2 JosiahK

JosiahK

  • Members
  • 269 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:05:32 AM

Posted 02 October 2011 - 01:52 AM

Does it work if you put the cout outside of the loop?
What is the text of the error message?

Edited by JosiahK, 02 October 2011 - 02:01 AM.

Quod non mortiferum, fortiorem me facit.
I don't read minds. Please help everyone by answering any questions and reporting on the results of any instructions. Query any concerns and explain problems or complications.

#3 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:10:32 PM

Posted 02 October 2011 - 08:32 AM

Are you including all of the proper libraries?

#4 Didier Stevens

Didier Stevens

  • BC Advisor
  • 2,685 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:06:32 AM

Posted 03 October 2011 - 02:38 AM

This means that the compiler doesn't know which cout you mean, it has several options to resolve cout in different namespaces.
You should post your complete program so we can see what headers you include and which namespaces you use/declare.

Didier Stevens
http://blog.DidierStevens.com
http://DidierStevensLabs.com

SANS ISC Senior Handler
Microsoft MVP 2011-2016 Consumer Security, Windows Insider MVP 2016-2019
MVP_Horizontal_BlueOnly.png

 

If you send me messages, per Bleeping Computer's Forum policy, I will not engage in a conversation, but try to answer your question in the relevant forum post. If you don't want this, don't send me messages.

 

Stevens' law: "As an online security discussion grows longer, the probability of a reference to BadUSB approaches 1.0"





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users