Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main() {
- char teste[25] ;
- char achar[25] ;
- printf("digite o texto: ");
- scanf("%[^\n]", &teste);
- getchar();
- printf("digite o texto de interesse: ");
- scanf("%[^\n]", &achar);
- getchar();
- int achei = 0, tag = 1;
- for (int i = 0; i < strlen(teste) && achei != 1; i++) {
- if (achar[0] == teste[i]) {
- tag = 1;
- for (int j = 1; j < strlen(achar) && tag != 0; j++) {
- if (achar[j] != teste[i + j]) {
- tag = 0;
- }
- }
- if (tag == 1) {
- achei = 1;
- }
- }
- }
- printf("%d", achei);
- return 0;
- }
Add Comment
Please, Sign In to add comment