Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.     char str1[32];
  7.     char str2[32];
  8.  
  9.     strcpy(str1, "String 1");
  10.     strcpy(str2, "String 2");
  11.  
  12.     printf("String values are \"%s\" \"%s\"\n", str1, str2);
  13.     int diff = strcmp(str1, str2);
  14.     printf("First string is %s than second\n", (diff == 1 ? "bigger" : "less"));
  15.     char str3[32];
  16.     strcpy(str3, str1);
  17.     strcat(str3, str2);
  18.     printf("Concatenation of two strings is \"%s\"\n", str3);
  19.     int ingpos = strstr(str3, "ing") - str3;
  20.     printf("First occurrence of word ing in \"%s\" is at position %d\n", str3,
  21.            ingpos);
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement