473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

%% in printf

I hope this is not a FAQ.

printf("%%%%");

What is the output for this? Is it implementation dependent?

TIA.

--
main(){char s[37]="CSbwjAjocpy/mw!PS!sbwjAeftqbnnfe/dpn";
int i;for(i=0;i<36;putchar(s[i++]-1));return 0;}
Nov 13 '05 #1
9 7055
On Sun, 09 Nov 2003 23:22:55 +0530, Ravi wrote:
I hope this is not a FAQ.

printf("%%%%");

What is the output for this?
"%%%%"
Is it implementation dependent?

no, AFAIK
Nov 13 '05 #2
On Sun, 09 Nov 2003 23:22:55 +0530, Ravi wrote:
I hope this is not a FAQ.

printf("%%%%");

What is the output for this? Is it implementation dependent?

TIA.


If you don't have a book that covers this sort of thing, go buy
one as soon as possible. ok?

In the meantime, here are some excerpts from the standard:

ISO/IEC 9899:1999 (E)

7.19.6.1

4 Each conversion specification is introduced by the character %.

8 The conversion specifiers and their meanings are:

% - A % character is written. No argument is converted. The complete
conversion specification shall be %%.

Nov 13 '05 #3
On Mon, 10 Nov 2003 05:08:27 +1100, ASiF wrote:

What is the output for this?


"%%%%"


sry typo
output would be:

%%
Nov 13 '05 #4
"Ravi" <ra**@despammed.com> wrote in message
news:bk********************************@4ax.com...
I hope this is not a FAQ.

printf("%%%%");

What is the output for this? Is it implementation dependent?


Yes, only after adding '\n' it will most certainly output %%, otherwise you
need fflush(stdout) to make it print %%
Nov 13 '05 #5

"Servé Laurijssen" <i@bleat.nospam.com> wrote in message
news:bo**********@news2.tilbu1.nb.home.nl...
"Ravi" <ra**@despammed.com> wrote in message
news:bk********************************@4ax.com...
I hope this is not a FAQ.

printf("%%%%");

What is the output for this? Is it implementation dependent?
Yes, only after adding '\n' it will most certainly output %%, otherwise

you need fflush(stdout) to make it print %%


Or end the program? I believe open files are flushed and closed when the
program end.

I have a number of times run into this problem in Java, where buffers are
not flushed and files closed, unless one explicitly closes them. (Close
does flush, yes.) It doesn't seem like too much to ask to me.

-- glen
Nov 13 '05 #6
"Servé Laurijssen" <i@bleat.nospam.com> wrote in message news:<bo**********@news2.tilbu1.nb.home.nl>...
"Ravi" <ra**@despammed.com> wrote in message
news:bk********************************@4ax.com...
I hope this is not a FAQ.

printf("%%%%");

What is the output for this? Is it implementation dependent?


Yes, only after adding '\n' it will most certainly output %%, otherwise you
need fflush(stdout) to make it print %%


Technically, the fflush is still insufficient to guarantee output of
the last line of a text stream. [However, it does typically address
the issue for consoles where it is a problem.]

--
Peter
Nov 13 '05 #7
On Sun, 9 Nov 2003 19:38:20 +0100, "Servé Laurijssen"
<i@bleat.nospam.com> wrote:
"Ravi" <ra**@despammed.com> wrote in message
news:bk********************************@4ax.com.. .
I hope this is not a FAQ.

printf("%%%%");

What is the output for this? Is it implementation dependent?
Yes,


When you say "yes" are you saying that it is implementation
dependent?
only after adding '\n' it will most certainly output %%, otherwise you
need fflush(stdout) to make it print %%


--
main(){char s[37]="CSbwjAjocpy/mw!PS!sbwjAeftqbnnfe/dpn";
int i;for(i=0;i<36;putchar(s[i++]-1));return 0;}
Nov 13 '05 #8
Greetings.

In article <j7********************************@4ax.com>, Ravi wrote:
On Sun, 9 Nov 2003 19:38:20 +0100, "Servé Laurijssen"
<i@bleat.nospam.com> wrote:
"Ravi" <ra**@despammed.com> wrote in message
news:bk********************************@4ax.com. ..
I hope this is not a FAQ.

printf("%%%%");

What is the output for this? Is it implementation dependent?


Yes,


When you say "yes" are you saying that it is implementation
dependent?


Yes, he is. (Given that there was only one yes-no question in your
original post, it's difficult to fathom what other interpretation one
could give this answer.)

--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\ http://www.nothingisreal.com/ >< To finish what you
Nov 13 '05 #9
"Ravi" <ra**@despammed.com> wrote in message
news:j7********************************@4ax.com...
printf("%%%%");

What is the output for this? Is it implementation dependent?


Yes,


When you say "yes" are you saying that it is implementation
dependent?


yes, but not in the manner you expected I guess. %% will print one % with
printf, but it's possible that nothing is printed if you omit the \n
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Grumble | last post by:
Hello, I have the following structure: struct foo { char *format; /* format string to be used with printf() */ int nparm; /* number of %d specifiers in the format string */ /* 0 <= nparm <=...
8
by: aditya | last post by:
hi, Can anybody please tell me that how the following printf(...) statement works- main(){ int d=9; printf("%d",printf("%d")); return 0;
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
188
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
29
by: whatluo | last post by:
Hi, c.l.cs I noticed that someone like add (void) before the printf call, like: (void) printf("Timeout\n"); while the others does't. So can someone tell me whether there any gains in adding...
4
by: pai | last post by:
Hi , Can any one tell me how this statement of printf is behaving . how the last digit is printed int a=2,b=4,c=7; printf("%d",printf("%d %d:",a,b)); //answer to this was 2 4:3
11
by: timmu | last post by:
Someone asked me a question about integer division and printf yesterday, I tell him he should do a casting to float/double before you do any interger division. But he doesn't think so, so I try...
19
by: RedDevilDan | last post by:
I am working on a Memory Footprint Reduction project. I came across an idea to disable all printf statements so that less memory is required. In addition, when there is no single printf statement,...
34
by: Old Wolf | last post by:
Is there any possible situation for printf where %hd causes a different result to %d, and the corresponding argument was of type 'short int' ?
1
by: linq936 | last post by:
Hi, I read in many places that the string to be outputted by printf() must be ending with newline, for example, it should be printf("Hello World.\n"); instead of printf("Hello World.");
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.