Jump to content

Saving message from message queue into file.

- - - - -

  • Please log in to reply
7 replies to this topic

#1
Mumble

Mumble

    Newbie

  • Members
  • PipPip
  • 14 posts
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.

#2
Ancient Dragon

Ancient Dragon

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 400 posts
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
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
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
geseeker

geseeker

    Newbie

  • Members
  • PipPip
  • 21 posts
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
Mumble

Mumble

    Newbie

  • Members
  • PipPip
  • 14 posts
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.

#6
Groogy

Groogy

    Programmer

  • Members
  • PipPipPipPip
  • 183 posts
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.

#7
Ancient Dragon

Ancient Dragon

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 400 posts
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
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
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