Download Eclipse IDE for C/C++ Developers Windows 32-bit at
http://www.eclipse.org/downloads/
http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/luna/SR2/eclipse-cpp-luna-SR2-win32.zip
Extract the zip file to
C:\eclipse-cpp-luna-SR2-win32
Don't name the folder as eclipse only
Create the following executable file shortcut on the desktop
C:\eclipse-cpp-luna-SR2-win32\eclipse.exe
Name the shortcut link as eclipse-cpp-luna-SR2-win32
Download and install CodeBlocks v13.12
http://www.codeblocks.org/downloads/
http://sourceforge.net/projects/codeblocks/files/Binaries/13.12/Windows/codeblocks-13.12mingw-setup.exe
Copy MinGW folder from
C:\Program Files (x86)\CodeBlocks\MinGW
to
C:\MinGW
Open Eclipse C++ IDE
Workspace: D:\my_cpp_2011
Tick the box "Use this as the default and do not ask again"
Click button OK
Click the Workbench curve down icon to start C++ programming
Eclipse Menu > Window > Preferences
Left menu > General > Editors > Text Editors
Tick the box "Insert spaces for tabs"
Tick the box "Show line numbers"
Click the button Apply
Left menu > C/C++ > Editor > Folding
Tick the box "Enable folding of preprocessor branches (#if/#endif)"
Tick the box "Enable folding of control flow statements (if/else, do/while, for, switch)"
Untick the box "Header Comments"
Click the button Apply
Left menu > C/C++ > New C/C++ Project Wizard
Check if you are on "Preferred Toolchains" tab
Go to "Project type" section box
Select "Empty Project" under Executable
Go to Toolchains section box
Select MinGW GCC row
Click the button "Make toolchain(s) preferred"
Click the button Apply
Click the button OK
Eclipse Menu > New > C++ Project
Project name: prjCpp3
Project type: Hello World C++ Project
Toolchains: MinGW GCC
Click button Finish
Go to Project Explorer frame
Right-click the prjCpp3 project folder > select "Build Project"
Right-click the prjCpp3 project folder > Run As > "1 Local C/C++ Application"
You can view the C++ code output in the Console frame
Replace the entire file content of prjCpp3.cpp with the following.
File name: prjCpp3.cpp
File content:
/**********/
/*
Output:
6 7 8
8
123
*/
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib> //for atoi
#include <sstream> //for sringstream
using namespace std;
int main(int argc, char* argv[])
{
//vector initialization list
vector<int> vec = {6, 7, 8};
//auto data type, range-based for loop using colon
for(auto elt : vec)
{
cout << elt << " ";
}
cout << endl;
//convert from int to string
//error: 'to_string' function is not available yet
//string s1 = to_string(vec[2]);
stringstream ss;
ss << vec[2];
string s1 = ss.str();
cout << s1 << endl;
//convert from string to int
//error: 'stoi' function is not available yet
string s2 = "123";
//int i = stoi(s2);
int i = atoi(s2.c_str());
cout << i << endl;
return 0;
}
/**********/
Go to Project Explorer frame
Right-click the project and go to Properties
Left menu > C/C++ Build > Settings > Tool Settings tab
Left menu > GCC C++ Compiler > Miscellaneous
Textfield: Other Flags: put "-std=c++11" at the end
Click button OK
Toolbar > click Run button
Close Eclipse C++ IDE
Reading. Practice. Writing.
Please feel free to comment. Suggestions are also welcomed here. Write something "wholesome serving purpose" here.
Subscribe to:
Post Comments (Atom)
Newton-Raphson Method in C++
The Newton Raphson Method is an open method used to find the roots of a function. It employs the technique of linear approximation and invol...
-
Open LibreOffice Draw program. Select the rectangle shape from shape toolbar at the bottom of drawing page. Click a point and drag-and-re...
-
DiGi Super Long Life is a feature where you can extend your talktime validity to 1 year for just RM38. Indirectly, the subscription fee is ...
-
DiGi Super Long Life is a feature where you can extend your talktime validity to 1 year for just RM30. Indirectly, the subscription fee is...
No comments:
Post a Comment