user-0 提问: C 语言程序求救： 编写一个 Windows embedded 输出语句的程序用来调整文字信息等功能。 [问题点数：40分]

回复:
user: user-0
content: 其中：   if(buff[i] != ' ')                 {                     oneword[j] = buff[i];                     i++;                     j++;                 }  中i++多余。

user: user-0
content: input.txt .br My name is Bob. My year is 24. .fi Your name if Hoj. HH. .sp 1 .sp 2 Here your tag. .ce 3 A dog is coming. You must go out of there. Or your home will burn. This is my pleasure. But can you give me this bag, I love it so much. .lm 5 You can, yeah, must do that. Or you will die. .rm 10 This is my iphone. That is your nokia, hhh. .ti 2 Jin tian tian qi hao qinglang. Chu chu hua er xiang. .lm 1 .rm 2 Wo Yeliangchen bufu.       output.txt   My name is Bob. My year is 24. Your name if Hoj. HH.        Here your tag.                        A dog is coming.                  You must go out of there.                   Or your home will burn. This is my pleasure. But can you give me this bag, I love it   so much.        You can, yeah, must do that. Or you will die. This is my        iphone. That is your nokia, hhh.     Jin tian tian qi hao qinglang. Chu chu hua er xiang.    Wo Yeliangchen bufu.

user: user-0
content: #include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h>   #define BUFFSIZE 60 #define BLANK 32 #define COMMANDLEN 4   int func(const char* inputFile, const char* outputFile) { 	char buff[BUFFSIZE]; 	char command[COMMANDLEN]; 	int NPos = 4; 	int spNValue = 0; 	char temp[3]; 	int temp2,temp3,temp4,temp5; 	int i = 0; 	int j = 0; 	int ceFlag = 0; 	int ceNValue = 0; 	int leftBegin = 0; 	int rightBegin = 60; 	int tiFlag = 0; 	int tiNValue = 0; 	int remainValue = 0; 	char oneword[60]; 	int leftBeginTemp = 0; 	int leftBeginChange = 0;  	FILE *pInputFile, *pOutputFile; 	pInputFile = fopen(inputFile, "r"); 	pOutputFile = fopen(outputFile, "w+"); 	 	if(!pInputFile && !pOutputFile)     {         printf("fopen error.\n");         return -1;     }   	while((fgets(buff, BUFFSIZE, pInputFile)) != NULL) 	{ 		if(buff[0] == '.') 		{ 			strncpy(command, buff, COMMANDLEN-1); 			command[COMMANDLEN-1] = '\0'; 			if(!strcmp(command,".br")) 			{ 				fputs("\r\n",pOutputFile); 				remainValue = 0; 			} 			if(!strcmp(command, ".fi")) 			{ 				continue; 			} 			if(!strcmp(command, ".sp")) 			{ 				int spNPos = NPos; 				for(i=0;isdigit(buff[spNPos]);i++) 				{ 					temp[0] = buff[spNPos]; 					temp[1] = '\0'; 					spNValue += atoi(temp); 					spNPos += 2; 				} 				if( i == 0 ) 				{ 					spNValue = 1; 				}  				for(i=0; i<spNValue; i++) 				{ 					fputc(BLANK, pOutputFile); 				} 				fputs("\r\n",pOutputFile); 				 				spNValue = 0; 				remainValue = 0; 			} 			if(!strcmp(command, ".ce")) 			{ 				fputs("\r\n",pOutputFile); 				ceFlag = 1; 				temp[0] = buff[NPos]; 				temp[1] = '\0'; 				ceNValue += atoi(temp); 			} 			if(!strcmp(command,".lm")) 			{ 				fputs("\r\n",pOutputFile); 				leftBeginChange = 1; 				if(!isdigit(buff[NPos])) 				{ 					leftBegin = 0; 				} 				else 				{ 					temp[0] = buff[NPos]; 					if(isdigit(buff[NPos+1])) 					{ 						temp[1] = buff[NPos+1]; 						temp[2] = '\0'; 					}else 					{temp[1] = '\0';} 					temp2 = atoi(temp); 					if(temp2<0 || temp2 >60) 					{ 						leftBegin = 0; 					} 					else 						leftBegin = temp2; 				} 			} 			if(!strcmp(command,".rm")) 			{ 				if(!isdigit(buff[NPos])) 				{ 					rightBegin = 60; 				} 				else 				{ 					temp[0] = buff[NPos]; 					if(isdigit(buff[NPos+1])) 					{ 						temp[1] = buff[NPos+1]; 						temp[2] = '\0'; 					}else 					{temp[1] = '\0';} 					temp2 = atoi(temp); 					if(temp2<0 || temp2 >60) 					{ 						rightBegin = 60; 					} 					else 						rightBegin = 60-temp2; 				} 			} 			if(!strcmp(command,".ti")) 			{ 				tiFlag =1; 				fputs("\r\n",pOutputFile); 				remainValue = 0; 				if(!isdigit(buff[NPos])) 				{ 					tiNValue = 0; 				} 				else 				{ 					temp[0] = buff[NPos]; 					if(isdigit(buff[NPos+1])) 					{ 						temp[1] = buff[NPos+1]; 						temp[2] = '\0'; 					}else 					{temp[1] = '\0';} 					tiNValue = atoi(temp); 				} 			} 		} 		else 		{ 		if(ceFlag) 		{ 			temp2 = strlen(buff); 			temp3 = (60-temp2)/2; 			for(j=0; j<temp3; j++) 			{ 				fputc(BLANK, pOutputFile); 			} 			fputs(buff,pOutputFile); 			ceNValue--; 			if(ceNValue == 0) 			{	ceFlag = 0;}	 		} 		else 		{ 			if(leftBeginChange != 0) 			{ 				remainValue = 0; 				leftBeginTemp = leftBegin; 				while(leftBeginTemp != 0 && remainValue <= rightBegin) 				{ 					fputc(BLANK, pOutputFile); 					remainValue++; 					leftBeginTemp--; 				} 				leftBeginChange = 0; 			} 			if(tiFlag) 			{ 				for(i = 0; i < tiNValue && remainValue <= rightBegin; i++) 				{ 					fputc(BLANK, pOutputFile); 					remainValue++; 				} 				tiFlag = 0; 				tiNValue =0; 			} 			 			j=0; 			temp4 = strlen(buff);   			for(i = 0; i< temp4; i++) 			{ 				if(buff[i] != ' ' && buff[i] != 10) 				{ 					oneword[j] = buff[i]; 					j++; 					continue; 				} 				oneword[j] = '\0'; 				temp5 = strlen(oneword); 				temp5 += remainValue; 				if(temp5 <= rightBegin) 				{ 					fputs(oneword,pOutputFile); 					fputc(BLANK, pOutputFile); 					remainValue = temp5; 				} 				else 				{ 					fputs("\r\n",pOutputFile); 					remainValue = 0; 					leftBeginTemp =leftBegin; 					while(leftBeginTemp != 0 && remainValue <= rightBegin) 					{ 						fputc(BLANK, pOutputFile); 						remainValue++; 						leftBeginTemp--; 					} 					fputs(oneword,pOutputFile); 					fputc(BLANK, pOutputFile); 					remainValue += strlen(oneword); 				} 				j=0; 				 			}   		} 		} 	} 	fclose(pInputFile); 	fclose(pOutputFile); 	return 0; }  void main() {     char *inputFileName = "input.txt";   //name of input file     char *outputFileName = "output.txt";  //name of output file     int n = func(inputFileName, outputFileName); 	printf("%d",n); 	system("pause"); }

user: user-1
content: 没准楼主要参考 FLEX+BISON

user: user-0
content: 不一定实现全部命令的功能。