C Language Archive
“%s”: It is format specifier %c represents single character. %s represents complete string(collection of characters) It is used to process(read & display) strings. Duplicate strings get different memory locations:
String will be terminated when it reaches ‘\0’ character: Note : Strings can be processed with \0 character only. ASCII value as follows. Note : In the above program, printf() function stops printing string when …
Display strings with quotes: Output : It is ‘C-lang’ class Output : It’s a C class Output : I am attending “C – Online” class Output : She said, “It’s a good one” Note: Array …
Reading string: “%s” can be used to read a string. “%s” will take the base address of memory block to read. To read a string(more than 1 character), loops are not required. Why we are …
strlen() : Find the length of string. Return +ve integer value (size_t) size_t is a datatype represents “unsigned” Prototype is size_t strlen(char s); Finding the length without using pre-defined function: Finding the length with user …
Convert UPPER string into LOWER string : Above program without using library function:
Reverse the string : This program reverses a string entered by the user. For example, if a user enters a string “reverse me” then on reversing the string will be “em esrever”. To reverse string …
strcmp(): It is Pre-defined function in string.h header file. Check the input strings are having same content or not. IF equal, returns 0. If not equal, returns non zero. strcmp() function consider the case. Lower …
void *memchr(const void *str, int c, size_t n) Searches for the first occurrence of the character c (an unsigned char) in the first n bytes of the string pointed to, by the argument str. int …
Primitive types: Using primitive variables, we can store only 1 value at a time. To store more than one value, number of variables need to be declared. It is complex to work with number of …