Skip to content

Instantly share code, notes, and snippets.

@timdrichards
timdrichards / pointer_arith_types.c
Last active March 30, 2022 16:23
C pointers, arithmetic, & types
#include <stdio.h>
#include <stdlib.h>
int main() {
char* c = malloc(10);
int* i = malloc(10);
// Print the size of a char and int type.
printf("Size of char is %lu.\n", sizeof(char));
printf("Size of int is %lu.\n", sizeof(int));
@timdrichards
timdrichards / cheat_sheet.txt
Created January 26, 2021 14:32
GDB cheat sheet
GDB commands by function - simple guide
---------------------------------------
More important commands have a (*) by them.
Startup
% gdb -help print startup help, show switches
*% gdb object normal debug
*% gdb object core core debug (must specify core file)
%% gdb object pid attach to running process
% gdb use file command to load object
@timdrichards
timdrichards / StringToInt.cc
Created September 24, 2012 15:22
Convert string to int
#include <string>
#include <iostream>
#include <sstream>
using namespace std;
int main() {
// This is how you would convert a C++ string into an integer:
string str1 = "45";
stringstream sstr1(str1);