-
weird thing with Microsoft visual studio...
I can't say I am an expert in programming as I took a few classes here and there, and I want to at least be able to improve my skill... Trying to play around with MS Visual studio (which includes VC++ and a bunch of other visual type tools I guess)
Well I can't seem to get standard C++ commands to work here... I can't use iostream.h because it gives me a file not found error... here's the code:
#include <iostream>
void main()
{
char name[10];
cout<<"\nEnter your name\n"<<endl;
cin>>name;
cout<<"\nYour name is "<<name<<endl;
}
(note: I am just trying to see if this works)
and the error it gives me
1>------ Build started: Project: test3, Configuration: Debug Win32 ------
1>Compiling...
1>test3.cpp
1>.\test3.cpp(6) : error C2065: 'cout' : undeclared identifier
1>.\test3.cpp(6) : error C2065: 'endl' : undeclared identifier
1>.\test3.cpp(7) : error C2065: 'cin' : undeclared identifier
1>.\test3.cpp(8) : error C2065: 'cout' : undeclared identifier
1>.\test3.cpp(8) : error C2065: 'endl' : undeclared identifier
1>Build log was saved at "file://c:\Documents and Settings\home\My Documents\Visual Studio 2008\Projects\test3\test3\Debug\BuildLog.htm"
1>test3 - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Also how do I make a basic windows program with VC++? So far I have only learned how to make console applications, and is OK with it, but I am stuck as to how to make a basic windows program that would for example have a textbox to enter something then the computer would process it (like display what you just entered into the textbox when you click OK). I have the algorithm in my head but could not get it to code...
Sorry I am a complete noob when it comes to this...
-
you forgot the line
using namespace std;
after <iostream>
without it, cout etc are scoped in some odd namespace (the fault of the standard) and you have to type something::cout to get at them.
For a gui program, you pick a gui project, then use make sure your app is "dialog based" in the project setup wizard. Then you can use the drag and drop windows programming editor to make simple apps.
-
 Originally Posted by jonnin
you forgot the line
using namespace std;
after <iostream>
without it, cout etc are scoped in some odd namespace (the fault of the standard) and you have to type something::cout to get at them.
For a gui program, you pick a gui project, then use make sure your app is "dialog based" in the project setup wizard. Then you can use the drag and drop windows programming editor to make simple apps.
I get what you're saying, but I mean do I still use the standard cin/cout commands for basic I/O or is there something else? for example textbox1 would go to a variable (not sure how to work that for a GUI) then upon clicking OK it would output that variable...
A tutorial on this would help (all the books/instructions on VC++ mostly taught things like cin/cout....)
-
i noticed the same thing when i was makeing a simple console program and found that useing include "iostream.h" instead actually worked it has something to do with how the precompiler proccess the file in how it searches for the path to use the librarys
or somtimes using the above mentioned std namespace
and i think that including certain files first may force you to use the std namespace which if ive done my reading right is to prevent ambigutys
Last edited by xlightwavex; 12-07-2007 at 06:34 AM.
-
no, you cannot redirect cin and cout to work in a gui. You use things like string = object.GetWindowText() or .SetWindowText for this.
<iostream.h> is obsolete now except in C, you are supposed to always use <iostream> and when you use it without the h, you need the using namespace std command or it will not work. This is due to a rather poorly thought out addition to the language a while back; it allows you to write your own cin and cout (or anything else) commands under a different namespace, which is a very bad idea IMO.
Similar Threads
-
By dotnet.deve in forum .NET
Replies: 2
Last Post: 01-17-2006, 09:22 AM
-
By Maria Jose Serres in forum dotnet.announcements
Replies: 0
Last Post: 02-19-2003, 02:54 PM
-
By joe smith in forum .NET
Replies: 2
Last Post: 08-30-2002, 02:03 PM
-
By Seth Grossman [MSFT] in forum .NET
Replies: 11
Last Post: 02-28-2002, 01:44 PM
-
By Spiker in forum Talk to the Editors
Replies: 10
Last Post: 07-21-2000, 08:29 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks