0
我使用VS 2013的專業和我建立一個控制檯應用程序。我的一個方法是從用戶輸入中確定字符串長度。我把這種方法的第5行接收一個令人困惑的錯誤:有一個缺少分號(錯誤C2143)。據我所知,該行內的任何函數都不需要額外的分號。另外,我故意不調用命名空間。將#include功能如下複製和存儲在頭文件。令人困惑的錯誤請求分號(錯誤C2143)
#include <stdio.h>
#include <tchar.h> //Part of VS' implementation for applications. Can effectively be ignored.
#include <iostream>
#include <string>
int main() {
std::string s;
std::cout << "Enter your string: " << std::flush;
std::string.getline(std::cin, s);
const int size = s.length();
std::cout << "The total number of characters entered is: " << size << std::endl;
}
@DyP沒有它不會。 –
哎呀,你說得對,有一個禁止它[dcl.dcl/3的特別規則。鏗鏘聲++只會發出警告。 – dyp