This is a draft cheat sheet. It is a work in progress and is not finished yet.
Java HelloWorld
class Hello {
static void sayHello() {
System.out.println("Hello World!");
}
public static void main(String args[]) {
sayHello();
}
}
|
|
|
C++ HelloWorld
#include <iostream>
using namespace std;
int main() {
cout << "Hello!" << endl;
return 0;
}
|
|
|
C HelloWorld
#include <stdio.h>
void sayHello() {
printf("Hello!");
}
int main() {
sayHello();
return 0;
}
|
C Basics
Ausgabe Int |
printf("%d ", 1); |
Ausgabe Str |
printf("%s ", "HelloWorld"); |
Ausgabe Char |
printf("%c ", "H"); |
Länge |
sizeof(s)/sizeof(int) |
Str Länge |
#include <string.h> strlen(str); |
Str setzen |
char s[] = "Hello World!"; |
UpperCase |
if (c >= 'a' && c <= 'z') c -= 32; |
statisch Array |
int values[] = {1,2,3,4}; |
dynamisch Array |
int* values = malloc(sizeof(int)*n); |
|