I have a problem with the program below. Line 31 give a warning of 3 dots (…) under the suf word suffix. I have attached a screenshot showing where the problem is and a message box stating what the problem is. If possible, can you fix this program problem please. Thank you Write a program in C++ that reads a sentence as input and converts each word to "Pig Latin." In one version, to convert a word to Pig Latin, your remove the first letter and place the letter at the end of the word. Then you append the string "ay" to the word. Here is an example: English:     I SLEPT MOST OF THE NIGHT Pig Latin: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY  Criteria program compiles 2) program solves problem according to specification 3) program declares, creates, or initializes static or dynamic array correctly 4) if required program defines function or functions with array parameters or array returns 5) program uses arrays to solve problem 6) program destroys any dynamic arrays     #include #include #include using namespace std;   string piglatin(string); string substr(string, int&);   int main() {     string input;     cout << "Enter a sentence: ";     getline(cin, input);     cout << "Piglatin: " << piglatin(input) << endl << endl;     return 0; } string piglatin(string input) {     int len = 0, counter = 0, start = 0, stop = 0;     string word = "", newstring = "";     do     {         word = substr(input, start); //translate the next word         start++;         newstring = newstring + word + " "; //add the word and a blank to the new sentence     } while (start < input.length());     return newstring; } string substr(string s, int& n) {     char word[50] = "", suffix[2]; // has warning, three ... under the suf of the word suffix[2];     int i = 0;     suffix[0] = s[n];    //get the first letter     suffix[1] = '\0';     n++;     while (s[n] != ' ' && s[n] != '\0') //copy letters from the input to the new word until end of the word     {         word[i] = s[n];         n++;         i++;     }     strcat(word, suffix); //add the suffix created to the new word     strcat(word, "ay"); //add "ay" to it     return word; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I have a problem with the program below. Line 31 give a warning of 3 dots (…) under the suf word suffix. I have attached a screenshot showing where the problem is and a message box stating what the problem is. If possible, can you fix this program problem please. Thank you

Write a program in C++ that reads a sentence as input and converts each word to "Pig Latin." In one version, to convert a word to Pig Latin, your remove the first letter and place the letter at the end of the word. Then you append the string "ay" to the word. Here is an example:

English:     I SLEPT MOST OF THE NIGHT

Pig Latin: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY

 Criteria

  • program compiles
    2) program solves problem according to specification
    3) program declares, creates, or initializes static or dynamic array correctly
    4) if required program defines function or functions with array parameters or array returns
    5) program uses arrays to solve problem
    6) program destroys any dynamic arrays

 

 

#include<iostream>

#include <cstring>

#include <string>

using namespace std;

 

string piglatin(string);

string substr(string, int&);

 

int main()

{

    string input;

    cout << "Enter a sentence: ";

    getline(cin, input);

    cout << "Piglatin: " << piglatin(input) << endl << endl;

    return 0;

}

string piglatin(string input)

{

    int len = 0, counter = 0, start = 0, stop = 0;

    string word = "", newstring = "";

    do

    {

        word = substr(input, start); //translate the next word

        start++;

        newstring = newstring + word + " "; //add the word and a blank to the new sentence

    } while (start < input.length());

    return newstring;

}

string substr(string s, int& n)

{

    char word[50] = "", suffix[2]; // has warning, three ... under the suf of the word suffix[2];

    int i = 0;

    suffix[0] = s[n];    //get the first letter

    suffix[1] = '\0';

    n++;

    while (s[n] != ' ' && s[n] != '\0') //copy letters from the input to the new word until end of the word

    {

        word[i] = s[n];

        n++;

        i++;

    }

    strcat(word, suffix); //add the suffix created to the new word

    strcat(word, "ay"); //add "ay" to it

    return word;

}

 

 

 

 

Homework13Problem2
| (Global Scope)
O substr(string s, int & n)
22
23
word- substr(input, start); //translate the next word
24
start++;
newstring - newstring + word + "; //add the word and a blank to the new sentence
} while (start < input.length());
return newstring;
25
26
27
28
Estring substr(string s, intå n)
30
29
char word[58] - "", suffix[2];
int i- e;
suffix[0] = s[n
suffix[1] - "le Add initializer
31
32
33
w fiect latter
34
Int1006: Local variable is not initialiced.
35
nt;
while (s[n] !-
{
word[i]
36
88 s[n] !-
end of the word
37
char word[5e] -
char word[50] -
int i- 0;
suffix[2];
suffix[2):
38
- s[n];
39
n++;
40
i+t;
41
strcat(word, suffix); //add the suffix created to the new word
strcat(word, "ay"); //add "ay" to it
return word;
42
100%
O No issues found
Ln: 31 Ch: 34 SPC
CRLF
Transcribed Image Text:Homework13Problem2 | (Global Scope) O substr(string s, int & n) 22 23 word- substr(input, start); //translate the next word 24 start++; newstring - newstring + word + "; //add the word and a blank to the new sentence } while (start < input.length()); return newstring; 25 26 27 28 Estring substr(string s, intå n) 30 29 char word[58] - "", suffix[2]; int i- e; suffix[0] = s[n suffix[1] - "le Add initializer 31 32 33 w fiect latter 34 Int1006: Local variable is not initialiced. 35 nt; while (s[n] !- { word[i] 36 88 s[n] !- end of the word 37 char word[5e] - char word[50] - int i- 0; suffix[2]; suffix[2): 38 - s[n]; 39 n++; 40 i+t; 41 strcat(word, suffix); //add the suffix created to the new word strcat(word, "ay"); //add "ay" to it return word; 42 100% O No issues found Ln: 31 Ch: 34 SPC CRLF
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education