Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int main(int ac,char** av){
- char* buf = 0;
- int capa = 0;
- int used = 0;
- for(;;){
- int c = getchar();
- if( c== -1 ) break;
- if( used +2 > capa ){
- capa = capa + 5;
- buf = (char*)realloc(buf,capa);
- if(buf==0){
- perror("メモリ不足");
- break;
- }
- }
- buf[used]=c;
- buf[used+1]=0;
- used ++;
- }
- if( buf != 0){
- printf("input is %s\n",buf);
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement