(STDIO, STDOUT, STDERR)
The main libraries in which C programs run
#include <stdio.h>
AND, OR, NOT, XOR
Specifies the parameters of the loop and determines if the loop should execute
while((x!='\0')&&(x!='\n'))
This is an AND operator in a program
taking one form of variable and making it fit into another form of variable
Demonstration of the chosen keyword.
If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:
#include <stdio.h> #include <stdlib.h> int main() { int *p1, *p2, p3, **p4; p1=(int*)malloc(sizeof(int)*1); *p1=26; printf("*p1 is %u\n", *p1); p2=p1; p4=&p1; printf("**p4 is %u\n",**p4); printf("*p2 is %u\n",*p2); *p2=61; printf("*p1 is %u\n", *p1); printf("**p4 is %u\n", **p4); printf("*p2 is %u\n", *p2); return(0); }
This allocated memory in the size of an int
Sets the memory address for something
#include <stdio.h> int main() { int a=0; int *b; b=&a; *b=12; printf("a contains %u\n", a); printf("a's address is 0x%x\n", &a); printf("b contains %u\n", *b); printf("b points to 0x%x\n", b); printf("b's address is 0x%x\n", &b); return(0); }
b is a pointer to a
Holds many different elements of the same data type at one address
#include <stdio.h> #include <stdlib.h> int main() { char *word, len=0, x, pos=0; word=(char *)malloc(sizeof(char)*24); fprintf(stdout, "Please enter a word: "); fscanf(stdin, "%s", word); printf("Debug A\n"); x=*(word+pos); printf("Debug A1\n"); while((x!='\0')&&(x!='\n')) { printf("in the while, x is %hhd\n",x); len++; pos++; x=*(word+pos); } printf("Debug B\n"); for(pos=0; pos<len; pos++) { fprintf(stdout, "%c", *(word+pos)-32);
read, write append
Creating a file and reading it into a program or writing the output of a program to a file
#include <stdio.h> #include <stdlib.h> int main() { FILE *in, *out; char value=0; in=fopen("file.txt", "r"); out=fopen("out.txt", "w"); if(in==NULL) { printf("ERROR!\n"); exit(1); n, *out; char value=0; in=fopen("file.txt", "r"); out=fopen("out.txt", "w"); if(in==NULL) if(in==NULL) if(in==NULL) } fscanf(in, "%hhd", &value); while(value !=-1) { value *=2; fprintf(out,"%hhd\n", value); fscanf(in, "%hhd", &value); } fclose(in); fclose(out); return(0); }
for, while, do while
These are loops that govern how many times a program will execute a certain task
/* * Sample code block */ #include <stdio.h> int main() { int v; while v!=0 { printf("Rise against the machines\n"); } else { printf(The machines have won\n") } return(0); }
Libraries
These are the #include statements at the beginning of a program. They are needed so that certain commands can be understood by the compiler to run a program
#include <stdio.h> #include <stdlib.h> #include <math.h>
There are others but these are just a few
comprehend the basics of memory management, data representation and storage
Can the student understand how to allocate memory and represent what they wish to represent with the proper file type? Does the student understand how to store values in C?
Explain the code of project 0
The code of project 0 is defining the size of the storage available for the different types of arguments in C. Each storage size dictates how much memory needs to be allocated for that type and whether or not datat will fit into that storage type.
I understand the logic behind most codes but will need to continue to work on writing the actual code.