admin's blog

Splitting string into words. Word contained in string. C language.

We are given 2 strings. We need to split strings into words and find word with minimal length contained in the first string, that is not contained in second string. Use function to check whether string contains a word.
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <alloc.h>
#include <ctype.h>
#include <limits.h>

char** words(char* str) {
        char** wrd;
        int i=0, j, k, l, n;
        wrd = (char**)calloc(1, sizeof(char*));

Splitting string into words. Array of pointers. C language.

We are given a string. We need to split a string into words and find a words with lenght more than 3. Use array of pointers to store words.

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <alloc.h>
#include <ctype.h>
#include <limits.h>

int main(int argc, char* argv[])
{
char *s1, *s[10];
int i=0, j, sim=0, l, k, h,  n1, n2, min;

s1 = (char*)calloc(100, sizeof(char));
puts("Enter string #1:");
gets(s1);
n1 = strlen(s1);
k = 0;
while (i < n1) {

Splitting string into words. Symmetrical words. C language.

We are given a string. We need to split a string into words and find a symmetrical words.

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <alloc.h>
#include <ctype.h>


int main(int argc, char* argv[])
{
char* s;
int i=0, j, sim=0, l, k, n;
s = (char*)calloc(100, sizeof(char));
puts("Enter string:");
gets(s);

n = strlen(s);

while (i < n) {
        while ( (i < n) && (!isalpha(s[i])) ) i++;
        j = i;
Subscribe to RSS - admin's blog