[try Beta version]
Not logged in

 
need help to change from array to pointer arithmetic

Sep 12, 2013 at 2:48am
#include <iostream>
#include <string>

using namespace std;

int main() {
char aString[] = "hello world";

cout << "aString = " << aString << endl;

for (int i = 0; aString[i] != '\0'; i++) {
if (aString[i] == ' '){
continue;
}

aString[i] = aString[i] - ' ';
}

cout << "aString = " << aString << endl;

return(0);
}
Sep 12, 2013 at 4:50am
What kind of help do you need? Maybe I missed the question. Perhaps instead of waiting for someone to do your homework for you, show us what you have so far in the rewrite, and then we'll see where you need some help.
Sep 14, 2013 at 12:12am
#include <iostream>
#include <string>

using namespace std;

int main() {
char aString[] = "hello world";
char *prt;
prt = aString;

cout << "aString = " << prt << endl;

for (int *prt = 0; *prt != '\0'; *prt++) {
if (*prt == ' '){
continue;
}

prt = prt- ' ';
}

cout << "aString = " << aString << endl;

return(0);
}
Sep 14, 2013 at 12:14am
This is what can i get from the change from array to pointer. the program doesn't capitalize letter the whole letters
Topic archived. No new replies allowed.