Theory
Write a C program to count occurrences of a word in a given string.
Without using pointer:
/**
* C program to copy one string to another string using while loop
*/
#include
#define MAX_SIZE 100 // Maximum size of the string
int main()
{
char text1[MAX_SIZE];
char text2[MAX_SIZE];
int i;
/* Input string from user */
printf("Enter any string: ");
gets(text1);
/* Copy text1 to text2 character by character */
i=0;
while(text1[i] != '\0')
{
text2[i] = text1[i];
i++;
}
//Makes sure that the string is NULL terminated
text2[i] = '\0';
printf("First string = %s\n", text1);
printf("Second string = %s\n", text2);
printf("Total characters copied = %d\n", i);
return 0;
}/**
* C program to copy one string to another string using pointer
*/
#include
#define MAX_SIZE 100 // Maximum size of the string
int main()
{
char text1[MAX_SIZE], text2[MAX_SIZE];
char * str1 = tex.... Show MoreFrom Strings in C programming · C programming
Write a C program to count occurrences of a word in a given string.
Write a C program to find total number of vowels and consonants in a string.
Write a C program to search all occurrences of a character in a string.
Write a program in C to find the largest and smallest word in a string.
Write a C program to concatenate two strings.
Write a C program to find maximum occurring character in a string.
Write a C program to find length of a string.
Write a C program to compare two strings