Write text to a file

Posted on February 14th, 2009 in Cpp by admin

This example uses streams to write text to a file

#include<iostream.h>
#include<fstream.h>

int main()

{
// first lets output to a file
ofstream fout(”sample.txt”);
fout << “programmershelp” << endl;
fout.close();
char str[20];
//read in the file
ifstream fin(”sample.txt”);
fin >> str;
fin.close();
//display sample.txt contents
cout << “data read from file: ” << str << endl;
return 0;
}

cppoctdechex

Posted on February 12th, 2009 in Cpp by admin

Octal / Hexadecimal / Decimal conversion

#include <iostream.h>
#include <iomanip.h> int main()
{
cout<<”The decimal value of 15 is “<<15<<endl;
cout<<”The octal value of 15 is “<<setiosflags(ios::oct)<<15<<endl;
cout<<”The hex value of 15 is “<<setiosflags(ios::hex)<<15<<endl;

return 0;

}

C++ Fundamentals

Posted on February 12th, 2009 in Cpp by admin

C++ Fundamentals

C++ is a programming language that is both procedure-oriented and object-oriented. VTC author Tim Heagarty builds on what you learned in C Programming and adds the basic structure and procedures of C++. With an emphasis on OOP you will learn constructors, classes, templates, exception handling and more. To start learning about C++ now, click on the links.

* Captions not yet available on CD version.

Introduction

Introduction
Short History of C++
C++ on Windows
Testing MS Visual C++ 2005 Express Edition
More MS Visual C++ 2005 Express Edition

Classes

Class Objects
Class Types
Data Members
Member Functions
Nested Types

Basic Structure

Fundamental Types
Linkage Of Names
One Definition Rule
Scope Of Names

Constructors

Enums

Class Member Access

Templates

Types & Arguments

Exception Handling