This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define size 30 | |
#include <cstdlib> | |
void allocate_array(int** array) { *array = new int[size]; } | |
int main() { | |
int* array; | |
allocate_array(&array); | |
int count; | |
for (count = 0; count < size; ++count) { | |
array[count] = count; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
enum month { JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC }; | |
const char* month_str[] = {"January", "February", "March", "April", | |
"May", "June", "July", "August", | |
"September", "October", "November", "December"}; | |
int main() { | |
enum month themonth; | |
for (themonth = JAN; themonth <= DEC; ++themonth) { | |
switch (themonth) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <limits> | |
int main(void) { | |
int count{}; | |
while(true) { | |
std::string s; | |
std::cout << "ctrl-d has been pressed " << count << " times " | |
<< std::endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <iostream> | |
int main(int argc, char * argv[]) { | |
//check for the correct args | |
if(argc != 3) { | |
std::cerr << "error: invalid args" << std::endl; | |
return EXIT_FAILURE; | |
} | |
//extract widht and height from the args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "IntList.h" | |
#include <climits> | |
Node::Node(int _data) : next(nullptr), data(_data) {} | |
void Node::setNext(Node* next) { this->next = next; } | |
Node* Node::getNext() { return next; } | |
int Node::getData() { return data; } | |
LinkedList::LinkedList() : head(nullptr), size(0) {} | |
void LinkedList::add(int data) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
result = 0 | |
for n in range(1,101): | |
result +=5*n*n | |
print (result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
def __init__(self, num: int) -> None: | |
self.num = num | |
self.next = None | |
class LinkedList: | |
def __init__(self): | |
self.len = 0 | |
self.head = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
struct alloc { | |
void* data; | |
long size; | |
}; | |
struct alloc thememory[BUFSIZ]; | |
struct alloc frees[BUFSIZ] = {0}; | |
long num_allocs = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
valgrind --track-origins=yes --leak-check=full --show-leak-kinds=all $@ |
NewerOlder