Showing posts with label function. Show all posts
Showing posts with label function. Show all posts

How to make parent process wait till Completion of Child Process (Joining parent with child process)

How to make the parent process wait till the completion of execution of child process. The following C program makes the parent process to wait till the completion of its child process.

#include<stdio.h>
main()
{

String Comparison in C and C++ Languages and Working of strcmp function

In both C and C++ programming languages, an inbuilt function strcmp() is used to compare two strings. This function is defined in string.h header file. So, to use this function, you have to include the header file string.h in the program. Most of the people ( i mean beginners) have a wrong idea about the working of the this function. I also had made some false assumptions. This function takes two strings as arguments. And it compares the two strings using the ASCII equivalent of each character. Some of the false ideas about this function are:
  • The function returns 1 when the strings are equal and 0 when they are not equal
  • The function returns 1 when they are not equal
  • The function returns 1 when the first string is greater than the second and returns -1 when the first one is less than the second one