How to printf the string "%d" itself?
I wonder how should I escape the %, since I see no escape char for % (in http://www.acm.uiuc.edu/webmonkeys/book/c_guide/1.1.html)
Thanks!
8 2191
To print % you should use % as the escape sequence.
Code will be
will print %
Raghu
char a[3]="%d";
printf("%s",a);
by using above two lines u can print %d itself
char a[3]="%d";
printf("%s",a);
by using above two lines u can print %d itself
I think the %% option would be much easier as u need not declare the local variable.
Raghuram
Yep,
In the end I did something like
It was meant to construct the string to pass later on to an fscanf() while reading a file.
Thanks,
Yep,
In the end I did something like
It was meant to construct the string to pass later on to an fscanf() while reading a file.
Thanks,
Hi,
You want to print % to console or have the % in a string to pass it to another function?
Raghu
I pass it to another function. Actually I was using sprintf() for that.
I pass it to another function. Actually I was using sprintf() for that.
If u are using sprintf then u can follow the same idea -
char arr[100];
-
sprinf(arr,"%%");
-
-
Then u can pass arr to the function u are using.
Raghu
Sign in to post your reply or Sign up for a free account.
Similar topics
by: infobahn |
last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
|
by: baumann |
last post by:
hi all,
i hope
printf("%#04x\n", 0);
will output 0x00,
but visual c++ studio 6 outputs 0000.
how can i get 0x00?
thanks
|
by: geek |
last post by:
Hi all,
Why does a printf("%d") statement prints this as output and when I do
printf("%c") it doesn't print anything.
-13361016
Any help would be appreciated.
Thanks,
|
by: Robin Tucker |
last post by:
Given the need to (possibly) alter the position of various elements in a
string due to localisation, is it possible to build a string using a
"printf" style function, such that the source string...
|
by: Jude |
last post by:
here is the source code:
#include<stdio.h>
int main()
{
float f;
scanf("%d%f",&f);
printf("The float is %10.5f\n",f);
return 0;
}
when I input 12345.11111,the output is 12345.11133.
|
by: v4vijayakumar |
last post by:
why the following statement dumps the core(Segmentation fault)?
printf("%s\n", __FILE__);
|
by: lovecreatesbeauty |
last post by:
Is parameter type conversion required for the 2nd argument on
printf("%p", (void *)&i); ?
But one would never call memcpy like:
memcpy((void *)pi, (void *)pj, sizeof *pj);
/*memcpy((void *)pi,...
|
by: Gernot Frisch |
last post by:
Hi,
class MyString
{
char* m_data;
public:
MyString(const char* c)
{
m_data = new char;
strcpy(m_data, c);
|
by: Ioannis Vranos |
last post by:
Is printf("%ls") for printing wchar_t strings defined in C90, or it was
added in C95?
|
by: Pietro Cerutti |
last post by:
Dear all,
Consider:
include <stdio.h>
int main(void)
{
printf("%d%d%d");
return (0);
}
|
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: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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: 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: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
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
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |