weird thing with Microsoft visual studio...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: weird thing with Microsoft visual studio...

  1. #1
    Join Date
    Dec 2007
    Posts
    2

    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...

  2. #2
    Join Date
    Dec 2003
    Posts
    3,366
    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.

  3. #3
    Join Date
    Dec 2007
    Posts
    2
    Quote 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....)

  4. #4
    Join Date
    Dec 2007
    Posts
    12
    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 07:34 AM.

  5. #5
    Join Date
    Dec 2003
    Posts
    3,366
    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

  1. visual studio 2003 & 2005:debugging issues
    By dotnet.deve in forum .NET
    Replies: 2
    Last Post: 01-17-2006, 10:22 AM
  2. ANN: Release of DeKlarit 2.0 for Microsoft Visual Studio .NET
    By Maria Jose Serres in forum dotnet.announcements
    Replies: 0
    Last Post: 02-19-2003, 03:54 PM
  3. Replies: 2
    Last Post: 08-30-2002, 03:03 PM
  4. YAG's status report - Feb 21, 2002
    By Seth Grossman [MSFT] in forum .NET
    Replies: 11
    Last Post: 02-28-2002, 02:44 PM
  5. Is anyone having...
    By Spiker in forum Talk to the Editors
    Replies: 10
    Last Post: 07-21-2000, 09: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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center