Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- void scanWord(char ** buff){
- char *buffer = NULL;
- size_t bufsize = 0;
- ssize_t bytesRead = getline(&buffer, &bufsize, stdin);
- if (bytesRead == -1) {
- perror("getline");
- return;
- }
- *buff = (char *) malloc(bytesRead * sizeof(char));
- strcpy(*buff,buffer);
- free(buffer);
- }
- int main()
- {
- char * word1, * word2;
- char* buff = NULL;
- printf("Introduceti primul cuvant: ");
- scanWord(&word1);
- printf("Introduceti al doilea cuvant: ");
- scanWord(&word2);
- size_t lenght1 = strlen(word1);
- size_t lenght2 = strlen(word2);
- if(lenght1 > lenght2){
- printf("Primul cuvant este cel mai lung");
- }else{
- printf("Al doilea cuvant este cel mai lung");
- }
- free(word1);
- free(word2);
- return 0;
- }
Advertisement
Comments
-
- https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&title=Untitled%20Diagram.drawio#Uhttps%3A%2F%2Fdrive.google.com%2Fuc%3Fid%3D1zgsXPJlr41KDYAybxi2sQuZdJ82qEXe3%26export%3Ddownload
Add Comment
Please, Sign In to add comment
Advertisement