
代码如下,如有帮助,请采纳一下,谢谢。
#include <stdio.h>
#include <string>
void main()
{
char** things ; //存储1000个商品
int i,j;
char buf[12];
things = new char*[1000];
for (i = 0; i < 1000;i++)
{
*(things+i) = new char[12];
sprintf_s(*(things+i),12,"%010d",i+1);
}
for (j = 0; j < 3; j++)
{
printf("%s\n",*(things+j) );
}
printf("请输入要查找的编号:");
scanf("%s",buf);
for (i = 0; i < 1000;i++)
{
if(strcmp(*(things+i),buf) == 0)
{
printf("位置:%d",i);
break;
}
}
if(i == 1000)
printf("找不到相应的产品\n");
for (i = 0; i < 1000; i++)
{
delete[] *(things+i);
}
delete[] things;
}