I am trying to implement some simple programs in C++ using MS VISUAL STUDIO 2008.
The program listed below gave the output correctly twice,but the next time I modified it by adding declaration for some variables and some cout statements as
int n1=1,n2=2,....n16=16;
cout<<n1;
it did not give any output but gave the errors which are listed below, after the program code.
The following is the program
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
int id=0,
nodeid1,
nodeid2,
nodeid3,
nodeid4,
nodeid5,
nodeid6,
nodeid7,
nodeid8,
nodeid9,
nodeid10,
nodeid11,
nodeid12,
nodeid13,
nodeid14,
nodeid15,
nodeid16;
nodeid1=1;
nodeid2=2;
nodeid3=3;
nodeid4=4;
nodeid5=5;
nodeid6=6;
nodeid7=7;
nodeid8=8;
nodeid9=9;
nodeid10=10;
nodeid11=11;
nodeid12=12;
nodeid13=13;
nodeid14=14;
nodeid15=15;
nodeid16=16;
cout<<"The LORD is good!\n\n";
cout << "Hello World!\n";
cout<<id;
cout<<n1;
return 0;
}
The following is the output window contents
1>------ Build started: Project: jprojectname, Configuration: Debug Win32 ------
1>Compiling...
1>jprojectname.cpp
1>c:\documents and settings\students\my documents\visual studio 2008\projects\jprojectname\jprojectname\jprojectname.cpp(46) : error C2065: 'n1' : undeclared identifier
1>Build log was saved at "file://c:\Documents and Settings\students\My Documents\Visual Studio 2008\Projects\jprojectname\jprojectname\Debug\BuildLog.htm"
1>jprojectname - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Could you tell what needs to be done in order to succesfulyy execute the porgram and get the output.
I have followed the following steps to create my program:
1.I created a new project,by clicking File-new-project-win32-win32console application
-then entered the name-clicked ok
-then I replaced t_main funtion by the code given in the end.
Then I saved the file.Then I followed the following steps.I clicked on the debug menu,debug-start without debugging
A message popped up asking
This project is out of date Would you like to build it?
The contents displayed above were obtained after selecting yes.
[edit]Code block added, "Treat my content as plain text..." option disabled - OriginalGriff[/edit]