What is the difference between strcmp and strncmp?


strcmp vs. strncmp

The basic difference between these two are:

  • strcmp compares both the strings till null-character of either string comes
  • strncmp compares at most num characters of both strings.
  • But if num is equal to the length of either string than strncmp behaves similar to strcmp.

Strcat function in C

What is the strcat function in C? (String Concatenation)

  • In the C Programming Language, the strcat function appends a copy of the string pointed to by s2 to the end of the string pointed to by s1.
  • It returns a pointer to s1 where the resulting concatenated string resides.

getchar and putchar in C

What is getchar and putchar in C?

  • putchar() function is a file handling function in C programming language which is used to write a character on standard output/screen.
  • getchar() function is used to get/read a character from keyboard input.

Library Functions in C

How many libraries are there in C?

  • ANSI Standard.
  • The ANSI C standard library consists of 24 C header files which can be included into a programmer’s project with a single directive.
  • Each header file contains one or more function declarations, data type definitions, and macros.
  • The contents of these header files follows.
  • Is Main () a library function in C?
  • These library functions are created at the time of designing the compilers.
  • We include the header files in our C program by using #include

Lascia un commento