The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > C / C++


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags: , , ,

Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 08-10-2007, 11:47 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Icon4 namespace std help!!!

This is really stressful lol... why doesn't it work? I don't see anything wrong with my code, here's my code and the error message:

Code:
#include<iostream>
#include"stdafx.h"
#include<stdlib.h>
usingnamespace std;
int main() {
int dice1 = 1 + rand() % 6;
int dice2 = 1 + rand() % 6;

cout << "Welcome to Carps" << endl;
return 0;
}
Error message:
Code:
1>------ Build started: Project: Carps, Configuration: Debug Win32 ------
1>Compiling...
1>Carps.cpp
1>c:\documents and settings\lltl16\my documents\visual studio 2005\projects\carps\carps\carps.cpp(5) : error C2871: 'std' : a namespace with this name does not exist
1>c:\documents and settings\lltl16\my documents\visual studio 2005\projects\carps\carps\carps.cpp(11) : error C2065: 'cout' : undeclared identifier
1>c:\documents and settings\lltl16\my documents\visual studio 2005\projects\carps\carps\carps.cpp(11) : error C2065: 'endl' : undeclared identifier
1>Build log was saved at "file://c:\Documents and Settings\lltl16\My Documents\Visual Studio 2005\Projects\Carps\Carps\Debug\BuildLog.htm"
1>Carps - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


here's one reason why that I think I should learn this by using Textpad instead lol.. so that I know what's really behind everything that Visual Studio has

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 08-10-2007, 12:02 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Code Update

I just updated my code, leaving one error.

I added,

Code:
#include <string>
and here's one error:
error C2065: 'cout' : undeclared identifier

Code:
1>------ Build started: Project: Carps, Configuration: Debug Win32 ------ 1>Compiling... 1>Carps.cpp 1>c:\documents and settings\lltl16\my documents\visual studio 2005\projects\carps\carps\carps.cpp(13) : error C2065: 'cout' : undeclared identifier 1>Build log was saved at "file://c:\Documents and Settings\lltl16\My Documents\Visual Studio 2005\Projects\Carps\Carps\Debug\BuildLog.htm" 1>Carps - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by HelloWorld : 08-10-2007 at 12:12 PM.
Reply With Quote
  #3 (permalink)  
Old 08-10-2007, 03:22 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Please mark this thread as SOLVED
I figured it out that's probably because I chose Win32 Console Application at the very beginning I create new project in Visual Studio 2005

Here's my fixed test code:
Code:
#include<iostream> #include<string> #include<stdlib.h> usingnamespace std; int main() { cout << "Test" << endl; return 0; }
There's no difference right? But I chose blank c++ project instead why ist hat happened? What's the difference between two?

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 08:05 AM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50