【发布时间】:2016-02-28 18:41:03
【问题描述】:
我创建了一个简单的程序,它为用户取名字并计算一个字母。 我在 Visual Studio 2015 中调试这个程序,但我有错误.. Error list image
#include "stdafx.h"
#include "iostream"
#include <cstdio>
#include <windows.h>
#include <conio.h>
using namespace std;
int main()
{
string name;
int name_number = name.length();
cout << "Your name: ";
cin >> name;
cout << name << endl;
cout << "Your name have: " << name_number << "letter";
return 0;
}
我在代码块中调试了同样的程序,一切正常,所以我不知道问题出在哪里..
【问题讨论】:
-
name.length() 在做 cin >> name 之前毫无意义。
标签: c++ visual-studio visual-studio-2015