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");}