Recently, I began to learn C ++ from Schildt’s book, C ++ Basic Course, and was learning how to handle pointers and their interaction with character arrays. Whether the code in the book is outdated, or VS 2012 fails, but I have complete disagreement between gets () and any character arrays, and another big problem is the complete failure of gets_s () (which works with character arrays and is a valid function) to read the data into the index character array According to Shildt, the code is correct, the header files are all that is needed. What could be the problem? In general, the whole point of the problem is that gets () does not work at all and that gets_s () does not perform all the necessary functions. Below is the code from the book Schildt for carbon paper.
#include <iostream> #include <cstring> #include <cstdio> #include <stdio.h> using namespace std; int main(){ setlocale(LC_ALL,"Russian"); char s[80]; int i=0; char *p; do { p = s; cout << "Введите строчку: "; gets(p); while(*p) { cout << (int) *p++ << ' '; i++;} cout << '\n'; }while(strcmp(s,"end")); }