write() bad address
c, linux
Solution
The second argument to `write()` is the address of the bytes you want to write, but you are passing the bytes you want to write themselves. In order to get an address, you must store those bytes in a variable (you can't take the address of the result of an expression). For example:
size_t patha_len = strlen(PATHA);
rtn = write(data, &patha_len, sizeof patha_len);
Problem
I am trying to write out the size in bytes of a string that is defined as `#define PATHA "/tmp/matrix_a"` using the code ``` rtn=write(data,(strlen(PATHA)*sizeof(char)),sizeof(int)); if(rtn < 0) perror("Writing data_file 2 "); ``` I get back `Writing data_file 2 : Bad address` What exactly about this is a bad address? The data file descriptor is open, and writes correctly immediately before and after the above code segment. The data to be written to the file `data` needs to be raw, and not ASCII. I have also tried defining the string as a char[] with the same issue