im new in C++
this is only a sample code:
note: the text with red font is the coz of "illegal operation" but if i change it to a same variable i dont recieve illegal operation but whenever line 14 is executed both variable b and a change to the value from the document.Code:#include <iostream> #include <fstream> using namespace std; int main () { char *a; char *b; char *c; char *d; ifstream ab ("word.txt"); ifstream bb ("wordlist.txt"); ab>>c; //line 11 b=c; cout<<b; bb>>d; //line 14 a=d; cout<<b<<a; cin.get(); }
this is the problem if i use same variable to line 11 and 14:
i change the variable c to d from line 11.
ab>>d;
b=d; meaning if string from the word.txt is aaaa, b = "aaaa"
when line 14 is executed
ab>>d;
a=d; if string from wordlist.txt is bbbb supposed to be a= "bbbb"
but b is also become b= "bbbb"
any help!!