Hello all,
I want to write the following line:
mtext(1, at=Graph, text=sprintf('%0.2f',MP$LR), line=1)
in a file (for example:Hist.R) in a function as follow:
void Graph()
{
FILE *RH=fopen("Hist.R","w");
..
..
..
fprintf(RH,"mtext(1, at=Graph, text=sprintf('%0.2f',MP$LR),
line=1)\n");
..
..
..
fclose(RH);
When I run the program, what program writes in the 'Hist.R' file
is:
mtext(1, at=Graph, text=sprintf('0.00',MP$LR), line=1)
it is '0.00' instead of '%0.2f'. Can anybody help me to solve
this problem?
Thanks,
Mohsen 2 4748
Mohsen wrote:
Hello all,
I want to write the following line:
mtext(1, at=Graph, text=sprintf('%0.2f',MP$LR), line=1)
in a file (for example:Hist.R) in a function as follow:
void Graph()
{
FILE *RH=fopen("Hist.R","w");
.
.
.
fprintf(RH,"mtext(1, at=Graph, text=sprintf('%0.2f',MP$LR),
line=1)\n");
.
.
.
fclose(RH);
When I run the program, what program writes in the 'Hist.R' file
is:
mtext(1, at=Graph, text=sprintf('0.00',MP$LR), line=1)
it is '0.00' instead of '%0.2f'. Can anybody help me to solve
this problem?
1) You need to double the % character in your string above, so that it
is interpreted by fprintf correctly.
2) Consider using iostreams instead of stdio.
Nate
Mohsen wrote:
.
fprintf(RH,"mtext(1, at=Graph, text=sprintf('%0.2f',MP$LR),
line=1)\n");
.
When I run the program, what program writes in the 'Hist.R' file
is:
mtext(1, at=Graph, text=sprintf('0.00',MP$LR), line=1)
it is '0.00' instead of '%0.2f'. Can anybody help me to solve
this problem?
fprintf(RH, "%s", "your stuff goes here");
or
fputs("your stuff goes here", RH);
What is currently happening is that fprintf treats your text as
a format string, so it does something with any '%' it sees. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: hpy_awad |
last post by:
I am writing stings ((*cust).name),((*cust).address)to a file using
fgets but rabish is being wrote to that file ? Look to my source
please and help me finding the reason why this rabish is being...
|
by: Smegly |
last post by:
Hi,
I'm confused about a situation i have ..
fprintf works in one function, but not in the other . .
This is my part of my code for the two functions ..
void customer(FILE *fin, FILE...
|
by: Andrew Fabbro |
last post by:
I have code with stuff like this all over it:
sprintf(errmsg,"somefunc(): %s has illegal character
%c",somestring,somechar);
fatal_error(errmsg);
where fatal_error() just fprintf's to stderr...
|
by: Magix |
last post by:
Hi,
I want to use fprintf to write to a file. My question about the formatted
output
How can I format so that I can allocate certain width for each %s
(Left-aignlied) ?
Example:
fprintf("%s...
|
by: G Patel |
last post by:
E. Robert Tisdale wrote:
>
> int main(int argc, char* argv) {
> quad_t m = {0, 1, 2, 3};
> int r;
> fprintf(stdout, "m = (");
> for (size_t...
|
by: baumann |
last post by:
hi all,
i want to use the fprintf to make log.
if defined LOG_TO_FILE, it is easy to use fprintf to write the log
file.
if not defined LOG_TO_FILE, i want to simply write to error std...
|
by: grimrob |
last post by:
fprintf just is not working. I am using PHP Version 4.3.9. Whatever I
do fprintf just fails.
For example:
fwrite($Handle, 'A1');
fprintf($Handle, 'A2);
The first line always works, the...
|
by: Prayag Narula |
last post by:
Hi,
I want to redefine fprintf for debugging purposes. That is I want that
all the output that is going to the stdout should be logged in a
file.
I tried something like
#define fprintf...
|
by: David Mathog |
last post by:
In the beginning (Kernighan & Ritchie 1978) there was fprintf, and unix
write, but no fwrite. That is, no portable C method for writing binary
data, only system calls which were OS specific. At...
|
by: vamsi |
last post by:
Hi,
I have a program, where involves creation of a thread with stack size
of 16k(minimum stack size). There is an fprintf statement in the
created thread code.
I see that there is a core dump...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |