Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
- #define N 100
- struct Sentence{
- char* sentence;
- };
- char* get_sent(char** string, int n){
- char* str = *string;
- int i = 0;
- char s;
- while(i < n){
- scanf("%c", &s);
- if(s == '.'|| s == '\n')
- break;
- else
- str[i] = s;
- i++;
- }
- str[i + 1] = '.';
- str[i + 2] = '\0';
- return str;
- }
- int main() {
- char* sent = malloc(N * sizeof(char));
- get_sent(&sent, N);
- struct Sentence my_sent = {sent};
- for(int i = 0; my_sent.sentence[i]; i++)
- printf("%c", my_sent.sentence[i]);
- free(sent);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement