1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include <iostream>
#include <cstring>
using namespace std;
int main() {
int strLength;
string custNumber, year, workOrderNumber;
char workOrder[] = {'9', '1', '8', '0', '0', 'w', '9', '4', '0', '7', '7', '0', '\0'};
char custNum[10] = { '\0'};
char * wPointer;
strLength = strlen(workOrder);
cout << "The length is " << strLength << endl;
wPointer = (char*) memchr (workOrder, 'w', strlen(workOrder));
if (wPointer!=NULL)
printf("The location of 'w' is %d \n", wPointer-workOrder);
custNumber = strncat(custNum, workOrder, 5);
cout << "The customer number is " << custNumber << endl;
cout << "The year of the order is " << year << endl;
cout << "The order number is " << workOrderNumber << endl;
return 0;
}
|