Skip to content

Commit d792d87

Browse files
committed
Added section10 related material.
1 parent 81335e9 commit d792d87

26 files changed

+1485
-0
lines changed
6 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Session Name="C:\Users\frank\Desktop\CPPExamples\Section10\Section10.workspace">
3+
<int Value="0" Name="m_selectedTab"/>
4+
<wxString Value="C:\Users\frank\Desktop\CPPExamples\Section10\Section10.workspace" Name="m_workspaceName"/>
5+
<TabInfoArray Name="TabInfoArray"/>
6+
<SerializedObject Name="m_breakpoints">
7+
<long Value="0" Name="Count"/>
8+
</SerializedObject>
9+
</Session>
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
##
2+
## Auto Generated makefile by CodeLite IDE
3+
## any manual changes will be erased
4+
##
5+
## Debug
6+
ProjectName :=CPPStrings
7+
ConfigurationName :=Debug
8+
WorkspacePath :=C:/Users/frank/Desktop/CPPExamples/Section10
9+
ProjectPath :=C:/Users/frank/Desktop/CPPExamples/Section10/CPPStrings
10+
IntermediateDirectory :=./Debug
11+
OutDir := $(IntermediateDirectory)
12+
CurrentFileName :=
13+
CurrentFilePath :=
14+
CurrentFileFullPath :=
15+
User :=frank
16+
Date :=31/01/2018
17+
CodeLitePath :="C:/Program Files/CodeLite"
18+
LinkerName :=C:/MinGW/bin/g++.exe
19+
SharedObjectLinkerName :=C:/MinGW/bin/g++.exe -shared -fPIC
20+
ObjectSuffix :=.o
21+
DependSuffix :=.o.d
22+
PreprocessSuffix :=.i
23+
DebugSwitch :=-g
24+
IncludeSwitch :=-I
25+
LibrarySwitch :=-l
26+
OutputSwitch :=-o
27+
LibraryPathSwitch :=-L
28+
PreprocessorSwitch :=-D
29+
SourceSwitch :=-c
30+
OutputFile :=$(IntermediateDirectory)/$(ProjectName)
31+
Preprocessors :=
32+
ObjectSwitch :=-o
33+
ArchiveOutputSwitch :=
34+
PreprocessOnlySwitch :=-E
35+
ObjectsFileList :="CPPStrings.txt"
36+
PCHCompileFlags :=
37+
MakeDirCommand :=makedir
38+
RcCmpOptions :=
39+
RcCompilerName :=C:/MinGW/bin/windres.exe
40+
LinkOptions :=
41+
IncludePath := $(IncludeSwitch). $(IncludeSwitch).
42+
IncludePCH :=
43+
RcIncludePath :=
44+
Libs :=
45+
ArLibs :=
46+
LibPath := $(LibraryPathSwitch).
47+
48+
##
49+
## Common variables
50+
## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables
51+
##
52+
AR := C:/MinGW/bin/ar.exe rcu
53+
CXX := C:/MinGW/bin/g++.exe
54+
CC := C:/MinGW/bin/gcc.exe
55+
CXXFLAGS := -std=c++14 -Wall -g -O0 -std=c++14 -Wall $(Preprocessors)
56+
CFLAGS := -g -O0 -Wall $(Preprocessors)
57+
ASFLAGS :=
58+
AS := C:/MinGW/bin/as.exe
59+
60+
61+
##
62+
## User defined environment variables
63+
##
64+
CodeLiteDir:=C:\Program Files\CodeLite
65+
Objects0=$(IntermediateDirectory)/main.cpp$(ObjectSuffix)
66+
67+
68+
69+
Objects=$(Objects0)
70+
71+
##
72+
## Main Build Targets
73+
##
74+
.PHONY: all clean PreBuild PrePreBuild PostBuild MakeIntermediateDirs
75+
all: $(OutputFile)
76+
77+
$(OutputFile): $(IntermediateDirectory)/.d $(Objects)
78+
@$(MakeDirCommand) $(@D)
79+
@echo "" > $(IntermediateDirectory)/.d
80+
@echo $(Objects0) > $(ObjectsFileList)
81+
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
82+
83+
MakeIntermediateDirs:
84+
@$(MakeDirCommand) "./Debug"
85+
86+
87+
$(IntermediateDirectory)/.d:
88+
@$(MakeDirCommand) "./Debug"
89+
90+
PreBuild:
91+
92+
93+
##
94+
## Objects
95+
##
96+
$(IntermediateDirectory)/main.cpp$(ObjectSuffix): main.cpp $(IntermediateDirectory)/main.cpp$(DependSuffix)
97+
$(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/frank/Desktop/CPPExamples/Section10/CPPStrings/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IncludePath)
98+
$(IntermediateDirectory)/main.cpp$(DependSuffix): main.cpp
99+
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/main.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/main.cpp$(DependSuffix) -MM main.cpp
100+
101+
$(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp
102+
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/main.cpp$(PreprocessSuffix) main.cpp
103+
104+
105+
-include $(IntermediateDirectory)/*$(DependSuffix)
106+
##
107+
## Clean
108+
##
109+
clean:
110+
$(RM) -r ./Debug/
111+
112+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CodeLite_Project Name="CPPStrings" Version="10.0.0" InternalType="User templates">
3+
<Plugins>
4+
<Plugin Name="qmake">
5+
<![CDATA[00010001N0005Debug000000000000]]>
6+
</Plugin>
7+
</Plugins>
8+
<Description/>
9+
<Dependencies/>
10+
<Settings Type="Executable">
11+
<GlobalSettings>
12+
<Compiler Options="-std=c++14;-Wall" C_Options="" Assembler="">
13+
<IncludePath Value="."/>
14+
</Compiler>
15+
<Linker Options="">
16+
<LibraryPath Value="."/>
17+
</Linker>
18+
<ResourceCompiler Options=""/>
19+
</GlobalSettings>
20+
<Configuration Name="Debug" CompilerType="MinGW ( MinGW )" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
21+
<Compiler Options="-g;-O0;-std=c++14;-Wall" C_Options="-g;-O0;-Wall" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
22+
<IncludePath Value="."/>
23+
</Compiler>
24+
<Linker Options="" Required="yes"/>
25+
<ResourceCompiler Options="" Required="no"/>
26+
<General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="./Debug" Command="./$(ProjectName)" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
27+
<BuildSystem Name="Default"/>
28+
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
29+
<![CDATA[]]>
30+
</Environment>
31+
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="yes">
32+
<DebuggerSearchPaths/>
33+
<PostConnectCommands/>
34+
<StartupCommands/>
35+
</Debugger>
36+
<PreBuild/>
37+
<PostBuild/>
38+
<CustomBuild Enabled="no">
39+
<RebuildCommand/>
40+
<CleanCommand/>
41+
<BuildCommand/>
42+
<PreprocessFileCommand/>
43+
<SingleFileCommand/>
44+
<MakefileGenerationCommand/>
45+
<ThirdPartyToolName>None</ThirdPartyToolName>
46+
<WorkingDirectory/>
47+
</CustomBuild>
48+
<AdditionalRules>
49+
<CustomPostBuild/>
50+
<CustomPreBuild/>
51+
</AdditionalRules>
52+
<Completion EnableCpp11="no" EnableCpp14="yes">
53+
<ClangCmpFlagsC/>
54+
<ClangCmpFlags/>
55+
<ClangPP/>
56+
<SearchPaths/>
57+
</Completion>
58+
</Configuration>
59+
<Configuration Name="Release" CompilerType="MinGW ( MinGW )" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
60+
<Compiler Options="-O2;-Wall" C_Options="-O2;-Wall" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
61+
<IncludePath Value="."/>
62+
<Preprocessor Value="NDEBUG"/>
63+
</Compiler>
64+
<Linker Options="" Required="yes"/>
65+
<ResourceCompiler Options="" Required="no"/>
66+
<General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="./Release" Command="./$(ProjectName)" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
67+
<BuildSystem Name="Default"/>
68+
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
69+
<![CDATA[]]>
70+
</Environment>
71+
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="yes">
72+
<DebuggerSearchPaths/>
73+
<PostConnectCommands/>
74+
<StartupCommands/>
75+
</Debugger>
76+
<PreBuild/>
77+
<PostBuild/>
78+
<CustomBuild Enabled="no">
79+
<RebuildCommand/>
80+
<CleanCommand/>
81+
<BuildCommand/>
82+
<PreprocessFileCommand/>
83+
<SingleFileCommand/>
84+
<MakefileGenerationCommand/>
85+
<ThirdPartyToolName>None</ThirdPartyToolName>
86+
<WorkingDirectory/>
87+
</CustomBuild>
88+
<AdditionalRules>
89+
<CustomPostBuild/>
90+
<CustomPreBuild/>
91+
</AdditionalRules>
92+
<Completion EnableCpp11="no" EnableCpp14="no">
93+
<ClangCmpFlagsC/>
94+
<ClangCmpFlags/>
95+
<ClangPP/>
96+
<SearchPaths/>
97+
</Completion>
98+
</Configuration>
99+
</Settings>
100+
<VirtualDirectory Name="src">
101+
<File Name="main.cpp"/>
102+
</VirtualDirectory>
103+
</CodeLite_Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./Debug/main.cpp.o
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#include <iostream>
2+
#include <iomanip>
3+
#include <string> // important!
4+
5+
using namespace std; // or use std::
6+
7+
int main() {
8+
9+
string s0;
10+
string s1 {"Apple"};
11+
string s2 {"Banana"};
12+
string s3 {"Kiwi"};
13+
string s4 {"apple"};
14+
string s5 {s1}; // Apple
15+
string s6 {s1, 0, 3}; // App
16+
string s7 (10, 'X'); // XXXXXXXXXX
17+
18+
cout << s0 << endl; // No garbage
19+
cout << s0.length() << endl; // empty string
20+
21+
// Initialization
22+
// cout << "\nInitialization" << "\n------------------------------------------" << endl;
23+
// cout << "s1 is initialized to: " << s1 << endl;
24+
// cout << "s2 is initialized to: " << s2 << endl;
25+
// cout << "s3 is initialized to: " << s3 << endl;
26+
// cout << "s4 is initialized to: " << s4 << endl;
27+
// cout << "s5 is initialized to: " << s5 << endl;
28+
// cout << "s6 is initialized to: " << s6 << endl;
29+
// cout << "s7 is initialized to: " << s7 << endl;
30+
31+
// Comparison
32+
// cout << "\nComparison" << "\n------------------------------------------" << endl;
33+
// cout << boolalpha;
34+
// cout << s1 << " == " << s5 << ": " << (s1 == s5) << endl; // True Apple == Apple
35+
// cout << s1 << " == " << s2 << ": " << (s1 == s2) << endl; // False Apple != Banana
36+
// cout << s1 << " != " << s2 << ": " << (s1 != s2) << endl; // True Apple != Banana
37+
// cout << s1 << " < " << s2 << ": " << (s1 < s2) << endl;; // True Apple < Banana
38+
// cout << s2 << " > " << s1 << ": " <<(s2 > s1) << endl; // True Banana > Apple
39+
// cout << s4 << " < " << s5 << ": " <<(s4 < s5) << endl; // False apple >Apple
40+
// cout << s1 << " == " << "Apple" << ": " <<(s1 == "Apple") << endl;; // True Apple == Apple
41+
42+
// Assignment
43+
// cout << "\nAssignment" << "\n------------------------------------------" << endl;
44+
//
45+
// s1 = "Watermelon";
46+
// cout << "s1 is now: " << s1 << endl; // Watermelon
47+
// s2 = s1;
48+
// cout << "s2 is now: " << s2 << endl; // Watermelon
49+
//
50+
// s3 = "Frank";
51+
// cout << "s3 is now: " << s3 << endl; // Frank
52+
//
53+
// s3[0] = 'C'; // Crank
54+
// cout << "s3 change first letter to 'C': " << s3 << endl; //Crank
55+
// s3.at(0) = 'P';
56+
// cout << "s3 change first letter to 'P': " << s3 << endl; // Prank
57+
58+
// Concatenation
59+
60+
// s3 = "Watermelon";
61+
// cout << "\nConcatenation" << "\n------------------------------------------" << endl;
62+
//
63+
// s3 = s5 + " and " + s2 + " juice"; // Apple and Banana juice
64+
// cout << "s3 is now: " << s3 << endl; // Apple and Banana Juice
65+
66+
// s3 = "nice " + " cold " + s5 + "juice"; // Compiler error
67+
68+
// for loop
69+
// cout << "\nLooping" << "\n------------------------------------------" << endl;
70+
//
71+
// s1 = "Apple";
72+
// for (size_t i {0}; i < s1.length(); ++i)
73+
// cout << s1.at(i); // or s1[i] Apple
74+
// cout << endl;
75+
//
76+
//// Range-based for loop
77+
// for (char c: s1)
78+
// cout << c; // Apple
79+
// cout << endl;
80+
81+
82+
// Substring
83+
// cout << "\nSubstring" << "\n------------------------------------------" << endl;
84+
// s1 = "This is a test";
85+
//
86+
// cout << s1.substr(0,4) << endl; // This
87+
// cout << s1.substr(5,2) << endl; // is
88+
// cout << s1.substr(10,4) << endl; // test
89+
90+
91+
// Erase
92+
// cout << "\nErase" << "\n------------------------------------------" << endl;
93+
//
94+
// s1 = "This is a test";
95+
// s1.erase(0,5); // Erase This from s1 results in "is a test"
96+
// cout << "s1 is now: " << s1<< endl; // is a test
97+
98+
// getline
99+
// cout << "\ngetline" << "\n------------------------------------------" << endl;
100+
//
101+
// string full_name {};
102+
//
103+
// cout << "Enter your full name: ";
104+
// getline(cin, full_name);
105+
//
106+
// cout << "Your full name is: " << full_name << endl;
107+
108+
// Find
109+
// cout << "\nfind" << "\n------------------------------------------" << endl;
110+
//
111+
// s1 = "The secret word is Boo";
112+
// string word {};
113+
//
114+
// cout << "Enter the word to find: ";
115+
// cin >> word;
116+
//
117+
// size_t position = s1.find(word);
118+
// if (position != string::npos)
119+
// cout << "Found " << word << " at position: " << position << endl;
120+
// else
121+
// cout << "Sorry, " << word << " not found" << endl;
122+
123+
cout << endl;
124+
return 0;
125+
}
126+

0 commit comments

Comments
 (0)