VC++新人求入门
我的情况是这样,学C大约半年了,初学C++几天,暑假没事干来实习一下,公司要我做code128条码生成程序,我源代码写出来了,但是他们要求我做成软件的样子来。因为之前写程序都是控制台程序,现在要做个软件出来不知道怎么弄,能不能有人给我点提示呢,我想在7月底之前做出来。最近也在看VC++的书了,可是还没有头绪
代码如下:
程序代码:
#define _CRT_SECURE_NO_WARNINGS #include <iostream> using namespace std; #define LENGTH 32 char *GetCode128 ( int ABC, char InPuts[], char OutBins[512]) { if ( ABC >=0 && ABC <=2) { static const char *c128[] = { "11011001100","11001101100","11001100110","10010011000","10010001100", "10001001100","10011001000","10011000100","10001100100","11001001000", "11001000100","11000100100","10110011100","10011011100","10011001110", "10111001100","10011101100","10011100110","11001110010","11001011100", "11001001110","11011100100","11001110100","11101101110","11101001100", "11100101100","11100100110","11101100100","11100110100","11100110010", "11011011000","11011000110","11000110110","10100011000","10001011000", "10001000110","10110001000","10001101000","10001100010","11010001000", "11000101000","11000100010","10110111000","10110001110","10001101110", "10111011000","10111000110","10001110110","11101110110","11010001110", "11000101110","11011101000","11011100010","11011101110","11101011000", "11101000110","11100010110","11101101000","11101100010","11100011010", "11101111010","11001000010","11110001010","10100110000","10100001100", "10010110000","10010000110","10000101100","10000100110","10110010000", "10110000100","10011010000","10011000010","10000110100","10000110010", "11000010010","11001010000","11110111010","11000010100","10001111010", "10100111100","10010111100","10010011110","10111100100","10011110100", "10011110010","11110100100","11110010100","11110010010","11011011110", "11011110110","11110110110","10101111000","10100011110","10001011110", "10111101000","10111100010","11110101000","11110100010","10111011110", "10111101110","11101011110","11110101110","10111011110","10111101110", "11101011110","11010000100","11010010000","11010011100","1100011101011" }; //1代表条,0代表空,详见code128标准 int ii, jj; int checksum= 103 + ABC; // A类 103 (ABC为0) B类 104 (ABC为1) C类 105 (ABC为2) int onAscii; memset(OutBins, '\0', sizeof(OutBins)); strcpy(OutBins, c128[106+ABC]); // 开头码:A类 106 (ABC为0) B类 107 (ABC为1) C类 108 (ABC为2) for (ii = 0 , jj = 1; ii < strlen(InPuts); ii++ , jj++) //主码和校验码算法 { onAscii = InPuts[ii] - 32; strcat(OutBins, c128[onAscii]); checksum = checksum + jj * onAscii; } checksum = checksum % 103; OutBins = strcat(OutBins, c128[checksum]); //校验码 strcat(OutBins,c128[109]); //终止码 return OutBins; } else { cout << "参数错误,需要编码的类别必须为:0 , 1 , 2" << endl; exit (0); } } int main(void) { char out[512]; char InPuts[ LENGTH ] = "0"; char buffer[512]; int ABC; int i; cout << "请选择需要编码的类别(A类则输入0,B类则输入1,C类则输入2):"; cin >> ABC; cout << "输入内容:"; cin >> InPuts; strcpy( buffer, GetCode128( ABC, InPuts, out)); //printf("输入的内容的条码为: %s\n", GetCode128( ABC, InPuts, out)); cout << "输入的内容的条码为: "; for( i = 0; i < strlen(buffer); i++) { if( buffer[i] == '1' ) cout << "*"; else cout << " "; } cout << endl; }