用stdio.h中gets_s函数时。参数使用的指针变量 出现错误,怎么不利用新定义一个指针常量来解决问题呢

/*
*用指针输出字符串并计算字符串的长度
*/
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    char* p, * q;
    p = new char[100];
    cout << p;
    gets_s(p);
    q = p;
    cout << "输出每个字符:";
    while (*p != 0)
        cout << *p++ << " ";
    cout << "\n字符串长度:" << p-q;
    return(0);
}

gets_s(p);
->
gets_s(p, 100);