Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Gotchas/C/gotchas-1.c
Normal file
3
Task/Gotchas/C/gotchas-1.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if(a=b){} //assigns to "a" the value of "b". Then, if "a" is nonzero, the code in the curly braces is run.
|
||||
|
||||
if(a==b){} //runs the code in the curly braces if and only if the value of "a" equals the value of "b".
|
||||
7
Task/Gotchas/C/gotchas-10.c
Normal file
7
Task/Gotchas/C/gotchas-10.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
int main()
|
||||
{
|
||||
int x = 3;
|
||||
int y = 5;
|
||||
int z = 7;
|
||||
printf("%d %d %d %x %x",x,y,z); //on an Intel cpu the first %x reveals %%ebp and the second reveals the return address.)
|
||||
}
|
||||
1
Task/Gotchas/C/gotchas-2.c
Normal file
1
Task/Gotchas/C/gotchas-2.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
int foo[4] = {4,8,12,16};
|
||||
4
Task/Gotchas/C/gotchas-3.c
Normal file
4
Task/Gotchas/C/gotchas-3.c
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
int foo[4] = {4,8,12,16};
|
||||
int x = foo[0]; //x = 4
|
||||
int y = foo[3]; //y = 16
|
||||
int z = foo[4]; //z = ?????????
|
||||
5
Task/Gotchas/C/gotchas-4.c
Normal file
5
Task/Gotchas/C/gotchas-4.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
int foo()
|
||||
{
|
||||
char bar[20];
|
||||
return sizeof(bar);
|
||||
}
|
||||
7
Task/Gotchas/C/gotchas-5.c
Normal file
7
Task/Gotchas/C/gotchas-5.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
int foo()
|
||||
{
|
||||
#define size_of_bar 20 //the sizeof operator is the same as doing this essentially.
|
||||
|
||||
char bar[size_of_bar];
|
||||
return size_of_bar;
|
||||
}
|
||||
4
Task/Gotchas/C/gotchas-6.c
Normal file
4
Task/Gotchas/C/gotchas-6.c
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
int gotcha(char bar[])
|
||||
{
|
||||
return sizeof(bar);
|
||||
}
|
||||
2
Task/Gotchas/C/gotchas-7.c
Normal file
2
Task/Gotchas/C/gotchas-7.c
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
myArray[40];
|
||||
int x = gotcha(myArray);
|
||||
2
Task/Gotchas/C/gotchas-8.c
Normal file
2
Task/Gotchas/C/gotchas-8.c
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
myArray[40];
|
||||
int x = gotcha(&myArray[0]);
|
||||
7
Task/Gotchas/C/gotchas-9.c
Normal file
7
Task/Gotchas/C/gotchas-9.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
int foo(char buf[],int length){}
|
||||
|
||||
int main()
|
||||
{
|
||||
char myArray[30];
|
||||
int j = foo(myArray,sizeof(myArray)); //passes 30 as the length parameter.
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue