Access violation with C++ -
i bit rusty c languages, , have been asked write quick little application take string stdin , replace every instance of letter 'a' letter 'c'. feel logic spot on (largely reading posts on site, might add), keep getting access violation errors. here code: #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> using namespace std; int main() { printf("enter string:\n"); string txt; scanf("%s", &txt); txt.replace(txt.begin(), txt.end(), 'a', 'c'); txt.replace(txt.begin(), txt.end(), 'a', 'c'); printf("%s", txt); return 0; } i can use insight. thank much! scanf doesn't know std::string is. c++ code should this: #include <string> #include <iostream> #include <algorithm> using namespace std; int main() { cout << "enter string:" << endl; string txt; cin ...