Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- struct Dictionary{
- char strings[1000][50];
- int n; // real size of array
- };
- bool twoStrings(char *string1, char *string2){
- if (strlen(string1) < strlen(string2)){
- return false;
- }
- else {
- int k = 0;
- while (k < strlen(string1)){
- if (string1[k] != string2[k]){
- return false;
- }
- k = k + 1;
- }
- return true;
- }
- }
- void stringThatStartsWithS(Dictionary *a, char *string){
- int k = 0;
- while (k < (*a).n){
- if (twoStrings((*a).strings[k], string) == true){
- printf("%s\n",(*a).strings[k]);
- }
- k = k + 1;
- }
- }
- int main() {
- Dictionary a;
- a.n = 5;
- int k = 0;
- while (k < a.n){
- printf("Print string in massive");
- scanf("%s", a.strings[k]);
- k = k + 1;
- }
- char string[50];
- printf("Write 2st string\n");
- scanf("%s",string);
- stringThatStartsWithS(&a, string);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement