Cplusplus Computer Science by Christopher Topalian
Cplusplus Computer Science by Christopher Topalian
Computer
Science
by
Christopher Andrew Topalian
Copyright 2000-2024
All Rights Reserved
Dedicated
to
God the Father
Download Visual Studio - Search Google
We Go To: google.com
Or we can go directly
to the Visual Studio website
as shown on the next page.
Download Visual Studio - Directly from Website
https://visualstudio.microsoft.com/vs/community/
We Go To:
https://visualstudio.microsoft.com/vs/community
Back Next
Project Name - 001
001
D:\_1Code\Cplus\001
We Choose: Add
main.cpp
D:\_1Code\Cplus\001
// main.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "Hi Everyone";
return 0;
}
// Building and Running our App
// main.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "Hi Everyone" << "\n";
return 0;
}
// Input from user
// main.cpp
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
return 0;
}
// Custom function - askName
// main.cpp
#include <iostream>
#include <string>
using namespace std;
string askName()
{
string name;
cout << "Enter Name: ";
cin >> name;
return name;
}
int main()
{
string userName = askName();
cout << "Hi, " << userName << "!" << "\n";
// main.cpp
#include <iostream>
#include <string>
using namespace std;
int main()
{
consoleLog("Hi Everyone");
return 0;
}
Header File - We define our function in a header
file for easy use
CONSOLELOG.h
D:\_1Code\Cplus\001
// CONSOLELOG.h
#ifndef CONSOLELOG
#define CONSOLELOG
#include <iostream>
#include <string>
#endif
// Our main.cpp file uses the CONSOLE.h file
// main.cpp
#include <iostream>
#include <string>
#include "CONSOLELOG.h"
using namespace std;
int main()
{
consoleLog("Hi Everyone");
return 0;
}
// PROMPT.h header file
// PROMPT.h
#ifndef PROMPT
#define PROMPT
#include <iostream>
#include <string>
#endif
// main.cpp uses CONSOLELOG.h and
PROMPT.h
// main.cpp
#include <iostream>
#include <string>
#include "PROMPT.h"
#include "CONSOLELOG.h"
using namespace std;
int main()
{
string input;
consoleLog("Enter Name");
prompt(input);
return 0;
}
File Structure of the previous Examples
// main.cpp
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct Person
{
string name;
int age;
};
int main()
{
vector<Person> people =
{
{
"Alice",
25
},
{
"Bob",
30
},
{
"Jane",
28
}
};
return 0;
}
// for loop diagram
Start number
FALSE
Exit test
TRUE
body
increment++
// for loop
// main.cpp
#include <iostream>
using namespace std;
int main()
{
for (int i = 1; i <= 100; i++)
{
cout << i << " ";
cout << "\n";
}
return 0;
}
// while loop diagram
start
FALSE
Exit test
TRUE
body
// while loop
// main.cpp
#include <iostream>
using namespace std;
int main()
{
int count = 0;
return 0;
}
// if else
#include <iostream>
#include <string>
using namespace std;
// main.cpp
int main()
{
string name;
cout << "Enter your name: ";
cin >> name;
if (name == "Chris")
{
cout << "Hi Chris.\nIt is good that you are
visiting Earth." << "\n";
}
else
{
cout << "Howdy " << name << ". "
<< "Tell Chris to Sign in later."
<< "\n";
}
cout << "\nPress Enter to Exit";
cin.ignore();
cin.get();
return 0;
}
C:\ D:\_1Code\Cplus\001\x64\Debug\001.exe
C:\ D:\_1Code\Cplus\001\x64\Debug\001.exe
// Open Browser to a URL
// main.cpp
#include <windows.h>
int main()
{
ShellExecuteA(NULL, "open",
"https://www.google.com", NULL, NULL,
SW_SHOWNORMAL);
return 0;
}
// Custom Function - Open Browser to a URL
// main.cpp
#include <windows.h>
#include <string>
using namespace std;
int main()
{
string url = "https://www.google.com";
openURL(url);
return 0;
}
// Create Text File with Data
// main.cpp
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
// open file for writing
std::ofstream outputFile("ourTextFile.txt");
// close file
outputFile.close();
return 0;
}
// Custom Function - Create Text File with Data
// main.cpp
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
writeToFile(filename, content);
return 0;
}
// Read a Text File
// main.cpp
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
return;
}
int main()
{
string filename = "ourTextFile.txt";
displayFileContents(filename);
return 0;
}
// Count Number of Lines in a Text File
// main.cpp
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
// open text file
std::ifstream inputFile("ourTextFile.txt");
return 0;
}
// How to Find Our Application .exe File
Search Solutions Explorer (Ctrl+;)
We put mouse arrow on: Solution '001' (1 of 1 project)
001
Solution '001' (1 of 1 project) References
External Dependencies
Header Files
Resource Files
Source Files
main.c
This PC > New Volume (D:) > _1Code > Cplus > 001
// main.cpp
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
wchar_t buffer[MAX_PATH];
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
/*
Current working directory: D:\_1CodeArc\
Cplus\001\x64\Debug
#include <iostream>
#include <windows.h>
int main()
{
// specify path of new folder
LPCWSTR folderPath = L"C:\\Users\\energy\\
Desktop\\ourNewFolder";
#include <iostream>
#include <windows.h>
#include <shlobj.h>
int main()
{
// get path of Documents folder
WCHAR documentsPath[MAX_PATH];
if (SHGetFolderPathW(NULL,
CSIDL_PERSONAL, NULL, 0, documentsPath) !
= S_OK)
{
std::wcerr << L"Error getting Documents
path" << std::endl;
return 1;
}
return 0;
}
// Make a New Folder on the Desktop
#include <iostream>
#include <windows.h>
#include <shlobj.h>
int main()
{
// get path of Desktop folder
WCHAR desktopPath[MAX_PATH];
if (SHGetFolderPathW(NULL,
CSIDL_DESKTOP, NULL, 0, desktopPath) !=
S_OK)
{
std::wcerr << L"Error getting Desktop
path" << std::endl;
return 1;
}
return 0;
}
True Artificial Intelligence System
16-Gon
Tautology
MI 1111 CI
1101 1011
AND XNOR
0001 1001
LP RP
0011 0101
OR NOR
0111 1000
RC LC
1010 1100
XOR NAND
0110 1110
CNI MNI
Contra-
0100 0010
-diction
0000
For More Tutorials:
CollegeOfScripting.weebly.com
CollegeOfScripting.wordpress.com
GitHub.com/ChristopherTopalian
GitHub.com/ChristopherAndrewTopalian
Youtube.com/ScriptingCollege
Twitter.com/CollegeOfScript
Rumble.com/user/CollegeOfScripting
Sites.google.com/view/CollegeOfScripting
Dedicated to God the Father
This book is created by the
College of Scripting Music & Science.
Always remember, that each time you write
a script with a pencil and paper, it becomes
imprinted so deeply in memory that the
material and methods are learned extremely
well. When you Type the scripts, the same is
true.
The more you type and write out the scripts
by keyboard or pencil and paper, the more
you will learn programming!
Write & Type EVERY example that you find.
Keep all of your scripts organized.
Every script that you create increases your
programming abilities.
SEEING CODE, is one thing,
but WRITING CODE is another.
Write it, Type it, Speak It, See It, Dream It.
www.CollegeOfScripting.weebly.com