C++ execution program Question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C++ execution program Question

Hello everyone, my code runs well but i am not able to make the screen display when i enter in my words. Would anyone be able to tell me where i went wrong. Here is my code: #include <iostream> using namespace std; class String { private: char strval[101]; public: String() { strval[0] = '\0'; }; String(char s[]) { int i = 0; while (s[i] != '\0') { strval[i] = s[i]; i++; } strval[i] = '\0'; } void ToCstring(char s[]) { int i = 0; while (s[i] != '\0') { strval[i] = s[i]; i++; } strval[i] = '\0'; } int Width() { int i = 0; while (strval[i] != '\0') { i++; } return i; } bool EqualTo(String s) { if (Width() != s.Width()) { return false; } else { for (int i = 0; i < Width(); i++) { if (strval[i] != s.strval[i]) { return false; } } } return true; } bool LessThan(String s) { int width = Width(); if (s.Width() < width) { width = s.Width(); } for (int i = 0; i < width; i++) { if (strval[i] > s.strval[i]) { return false; } } if (Width() < s.Width()) { return true; } return true; } bool GreaterThan(String s) { int width = Width(); if (s.Width() < width) { width = s.Width(); } bool equal = true; for (int i = 0; i < width; i++) { if (strval[i] < s.strval[i]) { return false; } else if (strval[i] != s.strval[i]) { equal = false; } } if (equal && Width() < s.Width()) { return false; } return true; } void Read() { cin >> strval; } void Write() { cout << strval << endl; } }; int main() { const int b = 101; int x; cout << "Number of Words Inputed is: "; cin >> x; while (x < 0 || x > 100) { cout << "Input Number (Range between 1 - 100)" << endl; cout << "Enter Number of Words Inputed: "; cin >> x; } String s1[b]; for (int i = 0; i < x; i++) {

20th Dec 2018, 9:20 PM
Amal Mukalel
Amal Mukalel - avatar
1 Answer
+ 2
Your code is cut off, please provide a link to your code by editing your post or commenting it and do so in the future.
20th Dec 2018, 10:28 PM
TurtleShell
TurtleShell - avatar