Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Сваляш си codeblocks http://www.codeblocks.org/ от тук
- и го инсталираш. След това от File -> New избираш
- нов проект, следваш wizard-a и и избираш C проект.
- Това просто го слагаш в main.c и цъкаш горе на
- менюто Build and Run. Може да търси в речника, но
- както виждаш там са само три думи:
- "table", "shoe" и "language". Пита те за
- думата и ако я намери изкарва значението и
- ако не я намери изкарва, че не е намерена.
- Това е. Можеш да си добавяш нови думи и значения, но
- не забравяй да увеличаваш тази цифра тук:
- *wordsCatalog[3]
- **/
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- #define SIZE_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
- int main()
- {
- char searchWord[65];
- bool searchTermIsFound = false;
- int i;
- const char *wordsCatalog[3][2] = {
- {"table", "a piece of furniture having a smooth flat top that is usually supported by one or more vertical legs"},
- {"shoe", "footwear shaped to fit the foot (below the ankle) with a flexible upper of leather or plastic and a sole and heel of heavier material"},
- {"language", "a systematic means of communicating by the use of sounds or conventional symbols"}
- };
- printf("Please. Type a word whose meaning you want to look in the dictionary: \n");
- scanf("%s", searchWord);
- for (i = 0 ; i < SIZE_OF_ARRAY(wordsCatalog); i++) {
- if (strcmp(searchWord, wordsCatalog[i][0]) == 0) {
- printf("Meaning of the word:\n%s", wordsCatalog[i][1]);
- searchTermIsFound = true;
- break;
- }
- }
- if (searchTermIsFound == false) {
- printf("Search term was not found in the dictionary.\n");
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment