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 <fstream> | |
#include <cmath> | |
using namespace std; | |
// Riff Chunk | |
const string RIFF_CHUNK_ID = "RIFF"; | |
const string RIFF_CHUNK_SIZE = "----"; |
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
/* ====================================================================== */ | |
/* Pointers & consts */ | |
/* ====================================================================== */ | |
/* POINTERS TO CONSTS */ | |
long value = 9999L; | |
long value2 = 1111L; | |
// only the value of what the pointer is pointing to is a constant | |
// we can still change the reference of what the pointer is pointing to |
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
// * - indirection operator | |
int *pNumber = NULL, myNum = 1; | |
char *my_str = "hello"; | |
long num1 = 0L, num2 = 0L, *pNum = NULL; | |
if (pNumber == NULL) | |
printf("pNumber is currently NULL\n"); | |
pNumber = &myNum; |
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
/* ====================================================================== */ | |
/* Void Pointers*/ | |
/* ====================================================================== */ | |
// void* absence of a type means you are able to store any type | |
// - Often used as a return type or a parameter type of functions | |
// - You must cast it to a type when you dereference it | |
int i = 10; | |
float f = 2.34; | |
char ch = 'k'; |
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
/* ====================================================================== */ | |
/* Pointers to Arrays */ | |
/* ====================================================================== */ | |
// point to first item in an array | |
char arr[] = {'a', 'b', 'c'}; | |
// apply the address operator to the first element in the array | |
char *arrPtr = &arr[0]; // without address operator you would get a value | |
// C compiler treats the array name (arr) without subscript ([]) | |
// as a pointer to the array. |
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
int main() | |
{ | |
/* ====================================================================== */ | |
/* Pointer Arithmetic */ | |
/* ====================================================================== */ | |
/* | |
int urn[3]; | |
int *ptr1, *ptr2 |
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
int main() | |
{ | |
char string1[] = "A string to be copied."; | |
char string2[50]; | |
copyStrong1(string2, string1); | |
return 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
#include <stdio.h> | |
#include <stdlib.h> | |
int calc_len_str(const char *str); | |
int main() | |
{ | |
char str[] = "How are you today!"; | |
int result = calc_len_str(str); | |
printf("result 1 = %d\n", 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
#include <stdio.h> | |
#include <stdlib.h> | |
void square_num(int *num); | |
int main() | |
{ | |
/* ====================================================================== */ | |
/* Pass By Reference */ |
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> | |
#include <string.h> | |
int main() | |
{ | |
/* ====================================================================== */ | |
/* Dynamic Memory Allocation */ | |
/* ====================================================================== */ | |
char *str = NULL; |
OlderNewer