C語言入門-基礎資料型別 (Elementary Data Type)和輸入輸出函數

來源:互聯網
上載者:User

C調用Java
#include <stdio.h>#include <stdlib.h>main(){      printf("Hello world !\n");      //c調用java,需把java源檔案編譯好,可以指定class的路徑      system("java -classpath E:\\ HelloWorld");      system("pause");}
C語言資料類型
#include <stdio.h>#include <stdlib.h>main(){      printf("int資料類型長度 int=%d\n",sizeof(int));      printf("short資料類型長度 short=%d\n",sizeof(short));      printf("long資料類型長度 long=%d\n",sizeof(long));      printf("char資料類型長度 char=%d\n",sizeof(char));      printf("float資料類型長度 float=%d\n",sizeof(float));      printf("double資料類型長度 double=%d\n",sizeof(double));           //C語言資料類型長度      /**        int資料類型長度 int=4        short資料類型長度 short=2        long資料類型長度 long=4        char資料類型長度 char=1 (可以替代java中的byte類型)        float資料類型長度 float=4        double資料類型長度 double=8      */           //java資料類型長度      /**        int 4個位元組, double 8個位元組,  float 4個位元組, long 8個位元組       short 2個位元組 ,boolean  1個位元組, char 2個位元組, byte 1個位元組      */              //signed, unsigned, 資料類型的修飾符       // signed int ; 代表的是有符號的int的資料       // unsigned int ;  無符號的int資料      printf("signed int的長度為%d\n", sizeof( signed int));      printf("unsigned int的長度為%d\n", sizeof( unsigned int));

      //signed int的長度為4
      //unsigned int的長度為4

       // 符號的修飾符 只能修飾 整數類型的資料 long int       // 不能修飾 浮點型的資料 float double        // printf("signed float的長度為%d\n", sizeof( signed float));            system("pause");}

C語言預留位置和輸入函數


#include <stdio.h>#include <stdlib.h>main(){      int i = 90;      long l = 45464;      short s = 7;      float f = 98.342423523f;      double d = 23.22525262;      char c = 'T';           /**各種資料類型的預留位置*/      printf("int %d\n",i);      printf("long %ld\n",l);      printf("short %d\n",s);      printf("float %f\n",f);      printf("double %lf\n",d);      printf("char %c\n",c);           char arr[10];      //輸入函數,阻塞式鍵盤輸入      scanf("%s",arr);//char數組預留位置為%s      printf("arr=%s\n",arr);           system("pause");}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.