Я устанавливаю указатели здесь один, чтобы указать на имя и один, чтобы снова указать на имя, но получить длину.Почему, когда я использую cout << strlen(tail);
, он продолжает говорить мне, что длина равна 3?Даже если я введу что-то 12?
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
char name[0];
cout << "Please enter your name: ";
cin.getline(name, 256);
cout << "Your name: " << name << endl;
char* head = name;
cout << head[6] << endl;
char* tail = name;
cout << strlen(tail);
return 0;
}