Sorry, this is what i have so far: (this is for a Loadrunner script, so some code with LR_ is made for that program)
This code does work except for finding the '/n' within this code
if ( ( nl = strchr( p, '\n' ) ) != NULL )
*nl = '\0';
I'm getting an error: "operands of = have illegal types `pointer to char' and `int'"
if i comment out the if statement, the code works, but there is a return after each order id (which i do not want)
Code:
Action() {
char *filename = "Inbound_OrderID_Copies.txt";
long file;
char longOrderID[30000] = { '\0', };
char * p = longOrderID; /** position in longOrderID **/
char * nl = NULL; /** find newline characters **/
size_t read, bufsiz;
strcpy( p, "Value=" );
bufsiz = sizeof longOrderID;
read = strlen( p );
p += read;
bufsiz -= read;
/** read in chunks: **/
if ((file = fopen(filename, "r")) == NULL ) {
lr_error_message("Cannot open %s", filename);
return -1;
}
while( bufsiz > 0 && fgets( p, bufsiz, file ) != NULL ) {
if ( ( nl = strchr( p, '\n' ) ) != NULL )
*nl = '\0';
strcat( p, "," );
read = strlen( p );
p += read;
bufsiz -= read;
lr_output_message("OrderID = %s", longOrderID);
}
return 0;
}