├── solutions └── chapter2 │ ├── frameProg │ └── frame.cpp ├── .gitignore └── LICENSE /solutions/chapter2/frameProg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/accelerated-cpp-solutions/master/solutions/chapter2/frameProg -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /solutions/chapter2/frame.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Frame program 3 | Author: Kaan 4 | Purpose: Program to display greetings with names in a frame 5 | Usage: Run the program, enter the name, witness the magic. 6 | 7 | */ 8 | 9 | // Declare Packages ------------ 10 | 11 | #include 12 | #include 13 | 14 | // End of Declare Packages ----- 15 | 16 | int main(){ 17 | // Enter your name 18 | std::cout << "Enter your name please: "; 19 | // Declare the local variable for 20 | // holding the name as string 21 | std::string user_first; 22 | std::string user_second; 23 | std::cin >> user_first >> user_second; 24 | const std::string user_name = user_first + " " + user_second; 25 | // Name with greeting as a const since we won't be changing it 26 | const std::string name_greeting = "Howdy dear " + user_name + " !"; 27 | // spaces of the name with greeting 28 | const std::string spaces(name_greeting.size(), ' '); 29 | // top row 30 | const std::string top_row(spaces.size(), '*'); 31 | // padding row 32 | const std::string pad_row = "* " + spaces + " *"; 33 | std::cout << "**" + top_row + "**" 34 | << std::endl; 35 | std::cout 36 | << pad_row 37 | << std::endl; 38 | std::cout 39 | << "* " + name_greeting 40 | << " *" 41 | << std::endl; 42 | std::cout 43 | << pad_row 44 | << std::endl; 45 | std::cout 46 | << "**" + top_row + "**" 47 | << std::endl; 48 | 49 | return(0); 50 | } 51 | --------------------------------------------------------------------------------