I got the output as
dfgd
Enter your string : The string is : dfgd
for the program below. The text "Enter your string " appear below the input section rather it requires being above the input of string. Any please help
#include<iostream>
using namespace std;
class activity4
{
private:
string chkSt;
public:
void stFn(string myStr)
{
cout<<"The string is : "<<myStr;
}
};
int main()
{
activity4 act;
char str[30], ch;
int i = 0;
cout<<"Enter your string : ";
while(ch != '\n')
{
ch = getchar();
str[i] = ch;
i++;
}
str[i] = '\0';
act.stFn(str);
return 0;
}
Bookmarks