c can you help me with this problem I can seem to figure out
c++,
can you help me with this problem I can seem to figure out a way to excute it?
Write a program that stores the string: \"Victory won\'t come to me unless I go to it\" into an array named str. Use the declaration: str [ ] =\"Victory won\'t come to me unless I go to it\" which ensures that the end of string escape sequence \'\\ 0 \' is included in the array. Display the characters in the array by changing the address in a pointer called *Pt. Use a for statement in your program. Modify the above program and make it to start the display from the first word which contains m.Solution
a)
#include <cstdio> // std:s:cin, std::cout
#include<map>
#include <fstream>
#include <iostream>
using namespace std;
int main () {
char str[]=\"Victory won\'t come to me unless I go to it\\0\";
char *ptr =str;
while(*ptr)
{
cout<<*ptr;
ptr++;
}
return 0;
}
b)
Code:
#include <cstdio> // std:s:cin, std::cout
#include<map>
#include <fstream>
#include <iostream>
using namespace std;
int main () {
char str[]=\"Victory won\'t come to me unless I go to it\\0\";
char *ptr =str;
string word=\"\";
int flag=0;
string res=\"\";
while(*ptr)
{
if((*ptr)!=\'m\' )
{
// if(*ptr)==\' \')
// word=\"\";
word+=(*ptr);
}
else
{
word+=(*ptr);
flag=1;
}
if(*ptr==\' \')
{
if(flag)
{
res+=word;
res+=\" \";
break;
}
word=\"\";
}
ptr++;
}
while(*ptr)
{
res+=(*ptr);
ptr++;
}
cout<<res;
return 0;
}

