(EXIT_FAILURE);case0:if(close(pipe_fd[1])==-1){perror("close - parent");exit(EXIT_FAILURE);}while(1){numRead=read(pipe_fd[0],buf,BUF_SIZE);if(numRead==-1){perror("read");exit(EXIT_FAILURE);}if(numRead==0)break;if(write(STDOUT_FILENO,buf,numRead)!=numRead){perror("...
free関数の基本的な使い方 free関数の一番簡単な使用例は下記になります。 free関数の使用例 #include<stdio.h>#include<stdlib.h>intmain(void){int*ptr =NULL;inti;/* ptrに確保したメモリの先頭アドレスを格納 */ptr = (int*)malloc(sizeof(int) *5);if(ptr ==NULL) {return-1; }/* 確...
18 Register as a new user and use Qiita more conveniently You get articles that match your needs You can efficiently read back useful information You can use dark theme What you can do with signing up Sign upLogin Comments No comments ...
if(Tk_Init(interp)==TCL_ERROR)//Tkを初期化(GUIライブラリをロード){constchar*errmsg=Tcl_GetStringResult(interp);//エラーメッセージの取得printf("GUIライブラリの初期化に失敗: %s\n",errmsg);return-1;}//コマンドを作るTcl_CreateCommand(interp,"testproc",proc,NULL,NULL);if(Tcl_Eval...
=NULL){if(buf[strlen(buf)-1]=='\n')buf[strlen(buf)-1]=0;str1=strdup(buf);for(intj=0;;j++,str1=NULL){token=strtok(str1," ");if(token==NULL)break;args[j]=token;args_num+=1;printf("%d: %s\n",j+1,args[j]);}free(str1);args[args_num]=(char*)NULL;if((pid=fork(...
strncmp(s+c,T[i],strlen(T[i]))){ k=strlen(T[i]); break; } } if(k<0){ puts("NO"); return 0; } c+=k; } puts("YES"); return 0; } 第10問 ABC086C Traveling dx+dyがdt以下かつdtとの偶奇が一致。 10.c //usr/bin/env picoc $0 - $@;exit #include <stdio.h> ...
ToString(); int len = 1; i++; if(i<cs.Length){ while(isdigit(cs[i].ToString())) { numberStr+= cs[i].ToString(); i++; len++; if(i>=cs.Length)break; } } cur = new_token(TokenKind.TK_NUM,next, numberStr,len); cur.val = strtol(numberStr); tokenList.Add(cur); next...
{char*str1,*token;if(argc!=3){fprintf(stderr,"Usage: %s string delim\n",argv[0]);exit(EXIT_FAILURE);}str1=strdupa(argv[1]);if(!str1)exit(EXIT_FAILURE);for(intj=1;;j++){token=strsep(&str1,argv[2]);if(token==NULL)break;printf("%d: '%s'\n",j,token);}exit(EXIT_...
[1-4]: ");input1=getchar();state=input1;switch(state){caseRUNNING:printf("Machine is running\n");break;caseSTOPPED:printf("Machine is stopped\n");break;caseFAILED:printf("Machine is in failed state\n");break;caseHIBERNATING:printf("Machine is hibernated\n");break;default:break;}exit...
break; case 't': /* Topic */ topic = (char*)strdup(optarg); break; case 'm': /* Message */ message = (char*)strdup(optarg); break; case 'd': /* debug mode */ is_debug = TRUE; break; default: usage(); } } /* topicとmessageが指定されていない場合、引数NG */ if((to...