The content here is unnoficial, and meant to aid the students enrolled in CS F111, Computer Programming. Please use these materials as they are intended - supplementary learning aids.
sort
, xinput
, wc
, head
, tail
Shell (Tran)Script
grep
Shell (Tran)Script
HW.c
, Linux.c
Dates.c
We received a question about pointers on our slack channel
from Tanmay Dixit recently. While the solution has been posted there, it would be nice if you could try this out.
Question: Predict the output of the following code snippet:
#include <stdio.h>
int main () {
int c[3] = {4, 5, 6}; // an array is basically a pointer to the first element
void *d = c; // cast int* to void*
d += 1; // increment the void pointer
printf("%08x\n", *((int *)d));
}
Now run it and see if you got the answer correct. Here is a simulation you can run that explains the output.
(Download the gist, compile with gcc simulation.c -w
and run with ./a.out
.)
If you have a better or simpler simulation, please leave a comment on the gist link.
If you would like to help build future screencasts, message @kaivalyar or @garvit_gupta on slack.
strcpy()
, strcmp()
and Segmentation Faults
strlen()
, strcat()
, strstr()
and atoi()