Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char* ReadStr() {
- int len, curr;
- char c;
- char* str;
- len = READSTRLEN;
- curr = 0;
- str = (char*)malloc(len * sizeof(char));
- fflush(stdin);
- c = getchar();
- while (c != 10) {
- if (curr >= len) {
- len += READSTRLEN;
- str = (char*)realloc(str, len * sizeof(char));
- }
- str[curr] = c;
- curr++;
- c = getchar();
- }
- str[curr] = 0;
- curr++;
- str = (char*)realloc(str, curr * sizeof(char));
- fflush(stdin);
- return str;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement