第一個c++程式,第一個c

來源:互聯網
上載者:User

第一個c++程式,第一個c
第一個c++程式

 

#include <iostream>

using namespace std;

int main(int argc, const char * argv[])

{

//cin接收鍵盤輸入

    int age;

    double height;

    char name[10];

//    cout 在控制台輸出一些資訊

//    相當於c語言的printf函數

//    相當於oc 中的NSLog

    cout << "請輸入年齡";

    cin >> age;

//    std::cout

//    cout這個對象是定義在std 命名空間中的

    cout << "請輸入身高";

    cin >> height;

    

    cout << "請輸入姓名\n";

//    cin >> name;

    cin.get(name,10);

//    endl  : end line

//    運算子重裁

    cout << "my age is " << age << ",height is " << height << ",name is " << name << endl ;

    return 0;

}

 


c-free 5隻可以運行第一個程式如果是程式,可以編譯運行多個,如果是工程,就只能運行一個,你把你的情況說清楚
對於初學c語言第一個程式的問題第一條回答真扯淡,main(void)是沒有參數,沒傳回值的void main(),你看是不是#include 跟<stdio.h>之間沒有空格,有些編譯器可以不用要空格,如Qt Creator,vs2012就不需要空格,但是我在keil裡面就需要空格,你可以先看看是不是這個原因,如果不是,你將錯誤原因發出來

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.