Hi,
I want to create a message queue which takes input from stdin and saves it in a file. I am able to read input from message queue. But, I am unable to store this message in a file.
Can anyone tell how to save message from message queue into a file?
Thanks,
Mumble.
7 replies to this topic
#1
Posted 21 July 2010 - 07:26 PM
|
|
|
#2
Posted 21 July 2010 - 08:17 PM
We have no clue what a message queue is, so you will just have to post the code.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.
#3
Posted 22 July 2010 - 12:45 AM
This is my best guess as to what you want:
#include <stdio.h>
.
.
.
char message[256];
scanf("%255s", message);
.
.
.
FILE *output = fopen("output_file_name.txt", "w");
fprintf(output, "%s", message);
.
.
.
fclose(output);
sudo rm -rf /
#4
Posted 22 July 2010 - 06:44 AM
I'm guessing you don't know how to write a file in C. In that case, you will want to refer to "file operations in C". Google it.
#5
Posted 23 July 2010 - 06:56 AM
Hi,
Thanks Dargueta.
I know how to write to a text file. But I am using message queue os IPC mechanism. And I ahve to read data from stdin into a message queue and from that message queue I have to write to a text file.
Do you have any idea how to read from message queue and then write to a text file?
Thanks,
Mumble.
Thanks Dargueta.
I know how to write to a text file. But I am using message queue os IPC mechanism. And I ahve to read data from stdin into a message queue and from that message queue I have to write to a text file.
Do you have any idea how to read from message queue and then write to a text file?
Thanks,
Mumble.
#6
Posted 23 July 2010 - 07:53 AM
Can you explain what a message queue is? Like how we interface to it? Is it an array of strings or do we have functions to query for the messages, etc. etc.?
My Code Blog - My Github - Ascension Project - Madness Script Project - Simple-Garbage-Collector Project
There is bound to be something useful somewhere.
There is bound to be something useful somewhere.
#7
Posted 23 July 2010 - 08:03 AM
I asked that question 2 days ago and he has not answered it yet. Since me mentioned IPC (inter process communications) maybe he is talking about pipes??? But that's just a guess.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.
#8
Posted 23 July 2010 - 08:56 AM
Can you get the information from the message queue into a buffer, like char mybuf[1024] or something?
sudo rm -rf /
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









