Last active
April 13, 2016 09:48
-
-
Save ahmedengu/46be4c9343b6523e64968292a4ae1133 to your computer and use it in GitHub Desktop.
read text and convert it to uppercase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <pthread.h> | |
#include <semaphore.h> | |
#include <ctype.h> | |
char inputString[100],uppercaseString[100]; | |
sem_t len; | |
void *reader() { | |
printf("Enter first text:"); | |
scanf("%s", inputString); | |
printf("\n %s", inputString); | |
sem_post(&len); | |
} | |
void *writer() { | |
sem_wait(&len); | |
for (int i = 0; i<100; i++) { | |
uppercaseString[i]=toupper(inputString[i]); | |
} | |
printf("\nUpper: %s", uppercaseString); | |
} | |
int main() { | |
pthread_t tid1,tid2; | |
pthread_create(&tid1, NULL, reader, NULL); | |
pthread_create(&tid2, NULL, writer, NULL); | |
pthread_join(tid1, NULL); | |
pthread_join(tid1, NULL); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5eukuei |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enter first text: | |
5eukuei | |
Upper 5EUKUEI |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment