October 2, 2017

C program to use string functions | Compare, concat, copy

Below is the video to you can watch and use the content below the video you can run on visual studio.

https://youtu.be/PNBB-bPsLz8



Concatenate two strings:
/* Function name: main
   Description: Start of program.
   Parameters: NA */
int main()
{
char user_input1[101];
char user_input2[101];
int a = 0;
/* Loops in C */
printf("\nPlease enter first string: ");
gets(user_input1);

printf("\nPlease enter second string: ");
gets(user_input2);

strcat(user_input1, " ");
strcat(user_input1, user_input2);

printf("\nOutput concatenated string is: %s\n", user_input1);
return 0;
}


String compare:

#include<stdio.h>

/* Function name: main
   Description: Start of program.
   Parameters: NA */
int main()
{
char user_input1[101];
char user_input2[101];
int a = 0;
/* Loops in C */
printf("\nPlease enter first string: ");
gets(user_input1);

printf("\nPlease enter second string: ");
gets(user_input2);

if (strcmp(user_input1, user_input2) == 0) {
printf("\nSuccess");
} else {
printf("\nFailure");
}

return 0;
}

String copy
#include<stdio.h>

/* Function name: main
   Description: Start of program.
   Parameters: NA */
int main()
{
char user_input1[101];
char user_input2[101];
int a = 0;
/* Loops in C */
printf("\nPlease enter first string: ");
gets(user_input1);

printf("\nPlease enter second string: ");
gets(user_input2);

strcpy(user_input1, user_input2);

printf("\nCopied string is: %s\n", user_input1);

return 0;
}

String length:
#include<stdio.h>

/* Function name: main
   Description: Start of program.
   Parameters: NA */
int main()
{
char user_input1[101];
char user_input2[101];
int a = 0;
/* Loops in C */
printf("\nPlease enter first string: ");
gets(user_input1);

printf("\Length of string is: %d\n", strlen(user_input1));

return 0;
}

September 21, 2017

C programming language | Using IF conditions and FOR/WHILE/DO-WHILE loops

Hey guys, here is another video of the C tutorial series, covered the IF conditions for loops, while loops and do while loops.
I know I am going very fast in the video, but this is all I can do in 10 minutes, I am trying not to split the video into more pieces.
Let me know how this looks by commenting below.