Jul 12, 2024
Editor de Texto
Compilador C
Download e Instalação do Code::Blocks
Configuração no Mac
cc -v
xcode-select --install
main
: Ponto de entrada do programa.#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
int
)double
)char
)int age = 30;
double gpa = 3.8;
char grade = 'A';
char name[] = "John";
==
, !=
, >
, <
, >=
, <=
&&
(e), ||
(ou)if (age > 18) {
printf("Adult\n");
} else {
printf("Minor\n");
}
for (int i = 0; i < 5; i++) {
printf("Number: %d\n", i);
}
void sayHi() {
printf("Hi!\n");
}
int main() {
sayHi();
return 0;
}
int sum(int a, int b) {
return a + b;
}
struct Student {
char name[50];
int age;
double gpa;
};
struct Student student1;
student1.age = 20;
int numbers[3] = {1, 2, 3};
int matrix[2][3] = {{1, 2, 3}, {4, 5, 6}};
int age = 30;
int *pAge = &age;
printf("Memory address: %p\n", pAge);
printf("Value: %d\n", *pAge);
FILE *fp = fopen("file.txt", "w");
fclose(fp);
fprintf(fp, "Hello, World!\n");
char line[255];
FILE *fp = fopen("file.txt", "r");
while (fgets(line, sizeof(line), fp)) {
printf("%s", line);
}
fclose(fp);