C/C++ | FreeBASIC |
int a; int a, b, c; | dim a as long dim as long a, b, c |
int a; | dim a as long = any |
int a = 0; | dim a as long |
int a = 123; | dim a as long = 123 |
int a[4]; a[0] = 1; | dim a(0 to 3) as long a(0) = 1 |
int a; int *p; p = &a; *p = 123; | dim a as long dim p as long ptr p = @a *p = 123 |
struct UDT { int myfield; } | type UDT myfield as long end type |
typedef int myint; | type myint as long |
struct UDT x; struct UDT *p; p = &x; p->myfield = 123; | dim x as UDT dim p as UDT ptr p = @x p->myfield = 123 |
int foo( void ); | declare function foo( ) as long |
int foo( void ) { return 123; } | function foo( ) as long return 123 end function |
void foo( void ); | declare sub foo( ) |
void foo( void ) { } | sub foo( ) end sub |
void foo( int param ); foo( a ); | declare sub foo( byval param as long ) foo( a ) |
void foo( int *param ); foo( &a ); | declare sub foo( byval param as long ptr ) foo( @a ) |
void foo( int& param ); foo( a ); | declare sub foo( byref param as long ) foo( a ) |
; | : <end-of-line> |
for (int i = 0; i < 10; i++) { ... } | for i as long = 0 to 9 ... next |
while (condition) { ... } | while condition ... wend |
do { ... } while (condition); | do ... loop while condition |
if (condition) { ... } else if (condition) {... } else {... } | if condition then ... elseif condition then... else... end if |
switch (a) { case 1: ... case 2:break; case 3: ... default:break; ... }break; | select case a case 1 ... case 2, 3... case else... end select |
char *s = "Hello!"; char s[] = "Hello!"; | dim s as zstring ptr = @"Hello!" dim s as zstring * 6+1 = "Hello!" |
#include <stdio.h> int main() { printf("Hello!\n"); }return 0; | print "Hello!" |
// foo /* foo */ | ' foo /' foo '/ |
#if a #elif b #else #endif | #if a #elseif b #else #endif |
#ifdef _WIN32 | #ifdef __FB_WIN32__ |
foo.c, foo.h | foo.bas, foo.bi |
gcc foo.c -o foo | fbc foo.bas |