Professional Documents
Culture Documents
Subject:C Programming Unit 4: C Header Files
Subject:C Programming Unit 4: C Header Files
Subject:C Programming Unit 4: C Header Files
Topics Covered:
1. time.h
2. stdlib.h
3. String.h
Submitted by,
Name: Kartavya Lajpal
Enrolment No:05817711922
Branch andSemester: AI&DS-Section-A, Ist Sem. Date:
01. time.h
The time.h header defines four variable types, two macro and various
functions for manipulating date and time.
NULL CLOCKS_PER_SEC
1 2 3
clock_t which is a part of the clock_t represents the date as struct tm holds the date and
calendar time represents the an integer which is a part of time.
date as an integer. the calendar time
Pre-defined Functions in
time.h
asctime() ctime()
This function returns the date and clock() This function returns the date
difftime()
time in the format This function returns and time in the format This function returns
day month date day month
hours:minutes:seconds year. the processor time hours:minutes:seconds year
the difference
Eg: Sat Jul 27 11:26:03 2019.
asctime() function returns a string
consumed by a Eg: Sat Jul 27 11:26:03 2019 between the times
time is printed based on the
by taking struct tm variable as a program pointer returned by Calendar
provided.
parameter.
Time
Programming Code:
Output:
01. stdlib.h
stdlib.h is the header of the general purpose standard library of C programming language which
includes functions involving memory allocation, process control, conversions and others. It is
compatible with C++ and is known as cstdlib in C++. The name "stdlib" stands for "standard
library".
This macro is the value of This is the value for the This is the value for the This macro is the
a null pointer constant. exit function to return in exit function to return in maximum value returned
case of failure. case of success. by the rand function.
MB_CUR_MAX
Programming Code:
Output:
01. string.h
The string.h header defines one variable type, one macro, and various functions for
manipulating arrays of characters.
Macros
NULL
void *memchr(const void *str, int int memcmp(const void *str1, void *memcpy(void *dest, void *memmove(void *dest,
c, size_t n) const void *str2, size_t n) const void *src, size_t n) const void *src, size_t n)
Searches for the first occurrence Copies n characters from src Another function to copy n
Compares the first n bytes of
of the character c (an unsigned characters from str2 to str1.
char) in the first n bytes of the str1 and str2. to dest.
string pointed to, by the argument
str.
Programming Code;
Output:
Output 1:
ope
Output 2:
Output 3: