9511_workbook

solved exercises from algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README
guia03/ex17.c (481B)
   1 /*    Makes a case sensitive search of the s2 in s1    */
   2 
   3 #include <stdio.h>
   4 #include <string.h>
   5 
   6 #define MAX_LEN 100
   7 
   8 int
   9 main (void)
  10 {
  11     char s1[MAX_LEN];
  12     char s2[MAX_LEN];
  13 
  14     /* Get two strings from stdin */
  15     if(!fgets(s1, MAX_LEN, stdin)) return 1;
  16     if(!fgets(s2, MAX_LEN, stdin)) return 1;
  17 
  18     if(strlen(s2) > strlen(s1)) return 1;
  19 
  20     for(size_t i = 0; s1[i]; i++)
  21         if(s1[i] == s2[0])
  22             for(size_t j = 0; s2[j]; j++)
  23                 if(s1[i] == s2[j])
  24                     putchar(s1[i++]);
  25                 
  26     return 0;
  27 }
  28 
  29