Advertisement
frentzy

Prototip cautare in string

Jan 22nd, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #include <iostream>
  5.  
  6.  
  7. void main() {
  8.     int n, i = 0, k;
  9.     char a[30];
  10.     char b[30];
  11.     char introducere;
  12.     //printf("text initial:%s\n", a);
  13.     while ((introducere = _getch()) != '\r') {
  14.         a[i] = introducere;
  15.         printf("%c", a[i]);
  16.         if (i < 29)
  17.             i++;
  18.         else break;
  19.        
  20.     }
  21.  
  22.     if (introducere == '\r')
  23.         a[i] = '\0';
  24.     introducere = 'a';
  25.     i = 0;
  26.     printf("\n");
  27.     while ((introducere = _getch()) != '\r') {
  28.         k = i;
  29.         b[i] = introducere;
  30.         printf("%c", b[i]);
  31.         if (i < 29)
  32.             i++;
  33.         else break;
  34.  
  35.     }
  36.     k++;
  37.     if (introducere == '\r')
  38.         b[i] = '\0';
  39.     printf("\n");
  40.     for (i = 0; i < 30; i++) {
  41.         if (a[i]!='\0')
  42.             printf("%c", a[i]);
  43.         else break;
  44.  
  45.     }
  46.     printf("\n");
  47.  
  48.     for (i = 0; i < 30; i++) {
  49.         if (b[i]!='\0')
  50.             printf("%c", b[i]);
  51.         else break;
  52.     }
  53.  
  54.     if (strstr(a, b) != NULL) {
  55.             printf("\ns-a gasit");
  56.     }
  57.     else printf("\nnu s-a gasit");
  58.     //printf("\na[0]=%c", a[0]);
  59.     //printf("\nb[0]=%c", b[0]);
  60.  
  61.     _getch();
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement