【原创】连接字符串数组

it2022-05-09  32

#include  < stdio.h > #include  < stdlib.h > char *  UnionStringArray( char *  StringArr[], int  iArrCount, char *  strTarget); int  main( int  argc,  char   * argv[]){   char *  billFields[ 11 =  { " product_id " , " product_class_id " , " product_name " , " product_unit " , " product_num " , " product_pym " ,                           " product_provider " , " purchase_date " , " remark " , " rec_status " , " operator " };   char  select_fields[ 1000 ] = "" ;    UnionStringArray(billFields, 11 ,select_fields);  printf( " %s\r\n " ,select_fields);                        system( " PAUSE " );       return   0 ;} char *  UnionStringArray( char *  StringArr[], int  iArrCount, char *  strTarget){    int  i;    for (i = 0 ;i < iArrCount;i ++ )   {       if (i < iArrCount - 1 )      {        strcat(strTarget, " t1. " );        strcat(strTarget,StringArr[i]);        strcat(strTarget, " , " );      }       else       {        strcat(strTarget, " t1. " );        strcat(strTarget,StringArr[i]);      }   }       return  strTarget;              }

 

该程序的测试环境:

WinXPSP2,Dev C++ 4.9.9.2

 

转载于:https://www.cnblogs.com/feima-lxl/archive/2010/08/05/1793223.html

相关资源:数据结构—成绩单生成器

最新回复(0)