0% found this document useful (0 votes)
3 views2 pages

Comprehensive C Language Guide

This document is a tutorial on the C programming language covering topics from basic to advanced levels. It includes chapters on variables, data types, control statements, functions, pointers, arrays, strings, structures, file I/O, and dynamic memory allocation. The section on dynamic memory allocation provides code examples using malloc and calloc functions, as well as memory management with free.

Uploaded by

Ayush
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Comprehensive C Language Guide

This document is a tutorial on the C programming language covering topics from basic to advanced levels. It includes chapters on variables, data types, control statements, functions, pointers, arrays, strings, structures, file I/O, and dynamic memory allocation. The section on dynamic memory allocation provides code examples using malloc and calloc functions, as well as memory management with free.

Uploaded by

Ayush
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C Language Tutorial

(Basic to Advanced)

Topics to be covered :
Installation + Setup
Chapter 1 - Variables, Data types + Input/Output
Chapter 2 - Instructions & Operators
Chapter 3 - Conditional Statements
Chapter 4 - Loop Control Statements
Chapter 5 - Functions & Recursion
Chapter 6 - Pointers
Chapter 7 - Arrays
Chapter 8 - Strings
Chapter 9 - Structures
Chapter 10 - File I/O
Chapter 11 - Dynamic Memory Allocation

Dynamic Memory Allocation


(Chapter 11)

# include <stdio.h>
# include <stdlib.h>
//Dynamic Memory Allocation

int main() {
//sizeof function
printf("%d\n", sizeof(int));
printf("%d\n", sizeof(float));
printf("%d\n", sizeof(char));

//malloc
// int *ptr;
// ptr = (int *) malloc(5 * sizeof(int));

// for(int i=0; i<5; i++) {


// scanf("%d", &ptr[i]);
// }

// for(int i=0; i<5; i++) {


// printf("number %d = %d\n", i+1, ptr[i]);
// }

//calloc
int *ptr = (int *) calloc(5, sizeof(int));

for(int i=0; i<5; i++) {


printf("number %d = %d\n", i+1, ptr[i]);
}

//free
free(ptr);

return 0;
}

You might also like