Hey! I'm learning C++ and pointers are pretty new to me, I can work with them a little but still don't see the point to them.. ok, well, I do.. For example, passing variables byReference! But that's the only good I see comming from pointers (yup, I'm a n00b)..
Ok, my question...
First of all, you can explain to me why pointers are so significant (if you want, otherwise I'll find out in time anyway I'm sure)? And secondly, I can't get something to work and I've been trying for hours.. Please make the following work!! I want to modify the value of a string using pointers, and a void method. I don't want to use any additional headers either.. Thanks! (this knowledge will benefit me forever)
#include <iostream>
using namespace std;
void ModStr(char * theStr);
int main(){
char strMyString[40];
cin >> strMyString;
ModStr(&strMyString);
cout << " value: " << strMyString << "\n";
return 0;
}
void ModStr(char * theStr){
*theStr = "This is the new text";
}
Why won't this work? Do I not have a clue what I'm doing? :rolleyes: