C 언어에서 long long 타입은 (부호가 있는) 64비트 정수 타입입니다.

win32 환경이라도 long long 타입을 C 언어에서 쓸 수 있습니다.

아래의 소스는

    Visual C++ 2010 Express

    Dev-C++

    LCC 컴파일러  또는  LCC-win32 컴파일러

   GCC 컴파일러

   TCC (Tiny-CC) 컴파일러

중 하나면 컴파일하여 실행시킬 수 있습니다.

 

TCC 로는 -run 옵션을 사용하여

    프롬프트>   tcc -run testLongLong.c

하면 (실행 파일 만들지 않고) 소스를 직접 실행시킬 수 있습니다.

 

 

// Filename: testLongLong_001.c
//
// Compile & Link: gcc -o  testComplexISOC99_002  testLongLong_001.c
// Execute: ./tesLongLong_001
//
// Or
//
// Compile & Link: cl testLongLong_001.c
// Execute: testLongLong_001
//
// Or
//
// Compile & Link: lc testLongLong_001.c
// Execute: testLongLong_001
//
// Or
//
// Compile: lcc -o testLongLong_001.obj testLongLong_001.c
// Link: lcclnk testLongLong_001.obj
// Execute: tesLongLong_001


#include <stdio.h>
#include <string.h>

int main(int argc, char** argv)
{
 long long a = 1000000000L;
 long long b = 1000000000L;
 char buf[100];

    printf("a * b = %lld * %lld = %lld\n", a, b, a*b);

    sprintf(buf, "%lld", a*b);
    printf("strlen(a * b) = strlen(%lld) = %d\n", a*b, strlen(buf));

    return 0;
}

/*
-------------------
Result of execution:
-------------------
a * b = 1000000000 * 1000000000 = 1000000000000000000
strlen(a * b) = strlen(1000000000000000000) = 19
*/

 

 

 

Posted by Scripter
,