Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void input_str();
- void printt(char *str, int i);
- int main() {
- input_str();
- /*
- int i = 10;
- for(int j = 0; j < i; j++) {
- printf("%c", str[j]);
- } */
- return 0;
- }
- void input_str() {
- char *str = malloc(sizeof(char));
- char c;
- int i;
- while (c!='\n') {
- scanf("%c", &c);
- *(str+i) = c;
- i++;
- char *str = realloc(str, i*sizeof(char));
- }
- printf("%d\n", i-1);
- for(int j = 0; j < i; j++) {
- printf("%c", *(str+j));
- }
- printt(str, i);
- }
- void printt(char *str, int i) {
- for(int j = 0; j < i; j++) {
- printf("%c", *(str+j));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement