This document summarizes the most commonly used functions within C, with name, way of programming and output. NOTE: some parts may be Dutch, but the programming stays the same nontheless.
0 1 0 0 1 1 0 1
0 0 1 1 0 1 0 1 0 1 0 0 1 1 0 1
------------------ | OR ------------------ ~ inverter
0 1 1 1 1 1 0 1 1 0 1 1 0 0 1 0
shifting shift left ( a << b) shift right ( a >> b)
a << 1 is gelijk aan a * 2 a >> 1 is gelijk aan a / 2
voorbeeld: 00001010 << 2 = 00101000 (dec. 10 -> dec. 40)
compound In C geldt: a += b; is hetzelfde als: a = a + b;
assignment Zo ook: a &= b; is hetzelfde als: a = a & b;
operator
Overzicht alle operatoren:
bit operatie byteValue |= 1 << 2; // set bit 2 op 1
byteValue &= ~(1 << 2); // set bit 2 op 0
print number void print_0_to_15() { 0= 0000 8= 1000
char i; 1= 0001 9= 1001
with bitwise for (i=0; i<=15; i++) { 2= 0010 10= 1010
operation printf("%2d= ", i); 3= 0011 11= 1011
print_char_binair(i); 4= 0100 12= 1100
printf("\n"); 5= 0101 13= 1101
} 6= 0110 14= 1110
} 7= 0111 15= 1111
include // om dubbele includes te voorkomen kun je gebruik maken van:
#ifndef PROGRAM1_H // if not defined: ‘PROGRAM1_H
#define PROGRAM1_H // define: ‘PROGRAM1_H’
[code voor program1.h]
#endif // end if defined
pointer int i = 8; // integer i met waarde 8
int *p; // pointer naar een integer /* - int i krijgt random adres 268
p = &i; // inhoud pointer - int pointer (*) p
p = adres van i - p krijg als inhoud 268 adres
printf("%d", *p); // print inhoud waar - *p = inhoud i (* heft & op)
pointer naar wijst */
8
struct struct datum {
uint8_t dag;
uint8_t maand;
uint16_t jaar;
}; // let op: puntkomma
int main() {
struct datum vandaag;
vandaag.dag = 19;
vandaag.maand = 9;
vandaag.jaar = 2017;
struct datum morgen = { 20, 9, 2017 };
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller richardreijerse. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $5.93. You're not tied to anything after your purchase.