1, 新建 delcrlf.cpp
2, 编写代码
#include <string>
#include <cstring>
#include <iostream>
#include <exception>
using namespace std;
char* delnewline(char *);
char* delnewline(char *badStr)
{
try
{
string crow = badStr;
int ilen = crow.size();
char *p = new char[ilen+1];
unsigned char fst = ' ';
for(int i = 0; i < ilen; ++i)
{
fst = (unsigned char)crow.at(i);
if( fst == 0x0A or fst == 0x0D )
{
p[i] = ' ';
} else {
p[i] = crow[i];
} ;
}
p[ilen]='\0';
return p;
}
catch(exception& e)
{
char *p = new char[5];
p[0] = '[';
p[0] = '@';
p[0] = '#';
p[0] = ']';
p[1] = '\0';
return p;
}
catch(...)
{
char *p = new char[5];
p[0] = '[';
p[0] = '@';
p[0] = '#';
p[0] = ']';
p[1] = '\0';
return p;
}
}
int main ( void ) {
char *ins = "1234";
char *out = delnewline(ins);
string ss = out ;
cout << ss << endl;
}
3, 编译看程序能否运行
g++ -o delcrlf delcrlf.cpp
./delcflf
确认是否有结果输出,如有,则表明C++程序无问题
4, 去除cpp文件中的 main 部分
5,创建makefile , 代码如下:
rm -f orchsort.o;
cp /app/dssrv/Ascential/DataStage/PXEngine/lib/orchsort.o ./
rm -f orchgeneral.o;
cp /app/dssrv/Ascential/DataStage/PXEngine/lib/orchgeneral.o ./
rm -rf delcrlf.o
rm -rf delcrlf_tmp.o
xlC -c -g -w -I/app/dssrv/Ascential/DataStage/PXEngine/include -I../incl -c delcrlf.cpp -o delcrlf_tmp.o
/usr/vacpp/bin/makeC++SharedLib -p 0 -L/app/dssrv/Ascential/DataStage/PXEngine/lib orchgeneral.o orchsort.o -lorchaix3 -lorchcoreaix3 -lm delcrlf_tmp.o -o delcrlf.o ;
6, 给makefile授权,且执行
7,新建parallel routine ,且使用,后续略