Just use /bin/echo and be done with it.Kirmie said:I've been trying to figure out how to use exec to print a string to a file. Trying tee but I don't want the user to enter it directly, I want to use a variable to input the string. Any help would be greatly appreciated.
Kirmie said:I'm stil getting confused so let me retry this. I have a string in char buffer[100] and I need to use a execlp call to put buffer on a line in phone.txt. I have to use the variable because of user input and I don't know how to get echo to send the output into phone.txt using execlp.
It's simple. You pass your buffer as an argument to /bin/echo command and redirect echo's output to target file. Invoke exec* function and you done. Following is an example:Kirmie said:I'm stil getting confused so let me retry this. I have a string in char buffer[100] and I need to use a execlp call to put buffer on a line in phone.txt. I have to use the variable because of user input and I don't know how to get echo to send the output into phone.txt using execlp.
HiRez said:Oh man...just looking at C++ code makes my head hurt. I've been spoiled by Obj-C.
It already is ObjC.WebMongol said:My code snippet is plain C. How do you rewrite it in Objective-C?
Technically any C code is an ObjC. But one can provide the same functionality using Cocoa API. Like in following snippet:iMeowbot said:It already is ObjC.
Oh, not your code above. Just in general. I think I was just in a bad mood.WebMongol said:My code snippet is plain C. How do you rewrite it in Objective-C?