void foo(int param){and it is called like
param = 5;
}
int x = 0;the value of x is still 0, because when foo() was called, the value was copied into a local variable called param
foo(x);
if(x = 1){}
printf("Hello, my name is %s and I am %d\n", "Luke", 18);
case 1:
int i;
scanf("%d\n", &i);
int x = 0;
x = my_array[3];
int hello[SIZE];
int x = 5; printf("The address %d halds the value %d in it\n", &x, x); // address as int which may be negative printf("The address %u halds the value %d in it\n", &x, x); // address as unsigned (positive) int printf("The address %x holds the value %d in it\n", &x, x); // address in hex (base 16)
char *x; // x is a pointer to char; its type is char * int *y; // y is a pointer to int; its type is int *
char *myPointer; char myChar = 'a'; myPointer = &myChar;
char *myPointer; char myChar = 'b'; myPointer = &myChar; printf("myPointer dereferenced is %c\n", *myPointer); // prints "myPointer dereferenced is b"
char a; char *myPointer = &a; *myPointer = 'b';
char my_array[3]; char* my_pointer; my_pointer = my_array + 3;
char my_array[3]; my_array = my_array + 3; // This will fail; you cannot change the address of an array EVER!
myPointer--; myPointer + 1; myPointer + i;
char word[] = "hello"
char *p; for(p = word; *p != '\0'; p++){ printf("%c", *p); }
int intArray[5] = {0, 5, 10, 15, 20}; int *myPointer; myPointer = intArray; printf("(myPointer+3) dereferenced is %d\n", myPointer[3]); // prints "(myPointer + 3) dereferenced is 15"
int main(int argc, char* argv[]){ char myChar; foo(&myChar); } void foo(char* myCharPointer){ *myCharPointer = 'a'; }
char* foo(char* myArray){ return myArray+1; }
if(myPointer == NULL) { do something }
if(myPointer == yourPointer) printf("We're pointing to the same thing!\n");
int a = 8 * 5;
char *a;
*a = 'c'; // where a is a pointer to a char
char a[50] = "hello"; a++;
char* myPointer; char myString[50] = "hello"; myPointer = myString;
int myMatrix[4][4]; myMatrix[0][0] = 1;
char myString[80] = "I am a string yay!"; char myString[] = "I am a string yay!"; char myString[] = {'I', ' ', 'a', 'm', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', 'y', 'a', 'y', '!', '\0'};
char *myString = "I am a unchangeable string yay!";
char myString[5]; myString[0] = 'H'; myString[1] = 'i'; myString[2] = '\0';
int result = 0; char test[10] = "hello"; result = strlen(test);
int result = 0; char test1[10] = "hello"; result = strcmp(test1, "goodbye");
int result = 0; char test1[10] = "good"; result = strcmp(test1, "goodbye", 4);
char source[10] = "mytest"; char destination[10]; char* ptr_to_dest; ptr_to_dest = strcpy(destination, source);
char source[10] = "mytest"; char destination[10]; char* ptr_to_dest; ptr_to_dest = strncpy(destination, source, 3);
char str1[20] = "hello "; char str2[20] = "world"; char* ptr_to_dest; ptr_to_dest = strcat(str1, str2);
char str1[20] = "abcdefg"; char* ptr_to_found_char; ptr_to_dest = strcat(str1, 'c');