I have a c program create_row which creates a database row using rand function.
I am redirecting its output to csv file
(./create_row param1 param2 param3 param4 > row.csv )
I have a printf inside program:
printf("%d,%s,% s,%s,,%s,%s,%05 d,%s,%1d,%s,%10 .0f,%1d,%16.0f, %s,%s,%s,%d,%d, %s\n",
customerid, firstname, lastname, address, city, state, zip, country, region, email, phone, creditcard_type ,
creditcard, creditcard_exp, username, password, age, income, gender);
Now if I run this on linux it creates linux format CR / LF file.
I do not want to use utilities in linux like dos2unix, unix2dos, perl, sed ,awk since I have to explicitly generate files first and then convert them to DOS format.
I want to achieve this in C program only.
Is there a way to replace \n by other character so that I get required format.
( My idea is to add other command argument to C program to indicate system_type (linux / win) and this printf will append correct characters acc to system and will generate files in correct format so that they need not be converted.
Do anybody have any idea how this can be achieved??
I am redirecting its output to csv file
(./create_row param1 param2 param3 param4 > row.csv )
I have a printf inside program:
printf("%d,%s,% s,%s,,%s,%s,%05 d,%s,%1d,%s,%10 .0f,%1d,%16.0f, %s,%s,%s,%d,%d, %s\n",
customerid, firstname, lastname, address, city, state, zip, country, region, email, phone, creditcard_type ,
creditcard, creditcard_exp, username, password, age, income, gender);
Now if I run this on linux it creates linux format CR / LF file.
I do not want to use utilities in linux like dos2unix, unix2dos, perl, sed ,awk since I have to explicitly generate files first and then convert them to DOS format.
I want to achieve this in C program only.
Is there a way to replace \n by other character so that I get required format.
( My idea is to add other command argument to C program to indicate system_type (linux / win) and this printf will append correct characters acc to system and will generate files in correct format so that they need not be converted.
Do anybody have any idea how this can be achieved??
Comment