Hi,
I think I can best ask my question by example. I may be overlooking
something, but this is like what I have:
#define ID1 'i'
#define ID2 'd'
#define ID3 'n'
This is what I want in my output file:
i=100:d=200:n=300
This is what I do:
sprintf("%c=%d:%c=%d:%c=%d\n",
ID1, 100,
ID2, 200,
ID3, 300);
That means that the characters are inserted run-time. Is there a way to
make them part of the string-constant so that I can put them into my string
compile-time?
Sorry if the question is formulated somewhat strange :) Thanks for any
help!
--
Martijn http://www.sereneconcepts.nl 5 1295
Martijn wrote: Hi,
I think I can best ask my question by example. I may be overlooking something, but this is like what I have:
#define ID1 'i' #define ID2 'd' #define ID3 'n'
This is what I want in my output file:
i=100:d=200:n=300
This is what I do:
sprintf("%c=%d:%c=%d:%c=%d\n",
You either forgot the buffer or use the wrong *printf() function.
ID1, 100, ID2, 200, ID3, 300);
That means that the characters are inserted run-time. Is there a way to make them part of the string-constant so that I can put them into my string compile-time?
Sorry if the question is formulated somewhat strange :) Thanks for any help!
Does
#define STRINGIZE(S) #S
#define XSTR(S) STRINGIZE(S)
#define ID1 i
....
printf(XSTR(ID1)"=%d",100)
help you or do you need the character constants elsewhere?
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Martijn wrote: Hi,
I think I can best ask my question by example. I may be overlooking something, but this is like what I have:
#define ID1 'i' #define ID2 'd' #define ID3 'n'
This is what I want in my output file:
i=100:d=200:n=300
This is what I do:
sprintf("%c=%d:%c=%d:%c=%d\n", ID1, 100, ID2, 200, ID3, 300);
That means that the characters are inserted run-time. Is there a way to make them part of the string-constant so that I can put them into my string compile-time?
sprintf("i=%d:d=%d:n=%d\n", 100, 200, 300);
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
CBFalconer <cb********@yahoo.com> scribbled the following: Martijn wrote: Hi,
I think I can best ask my question by example. I may be overlooking something, but this is like what I have:
#define ID1 'i' #define ID2 'd' #define ID3 'n'
This is what I want in my output file:
i=100:d=200:n=300
This is what I do:
sprintf("%c=%d:%c=%d:%c=%d\n", ID1, 100, ID2, 200, ID3, 300);
That means that the characters are inserted run-time. Is there a way to make them part of the string-constant so that I can put them into my string compile-time?
sprintf("i=%d:d=%d:n=%d\n", 100, 200, 300);
A very nice solution, but you're still using sprintf() in the wrong way.
Do you mean printf()?
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"There's no business like slow business."
- Tailgunner
Joona I Palaste wrote: CBFalconer <cb********@yahoo.com> scribbled the following: Martijn wrote: I think I can best ask my question by example. I may be overlooking something, but this is like what I have:
#define ID1 'i' #define ID2 'd' #define ID3 'n'
This is what I want in my output file:
i=100:d=200:n=300
This is what I do:
sprintf("%c=%d:%c=%d:%c=%d\n", ID1, 100, ID2, 200, ID3, 300);
That means that the characters are inserted run-time. Is there a way to make them part of the string-constant so that I can put them into my string compile-time?
sprintf("i=%d:d=%d:n=%d\n", 100, 200, 300);
A very nice solution, but you're still using sprintf() in the wrong way. Do you mean printf()?
Yup. I guess the OP did also.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
On Thu, 24 Mar 2005 00:10:06 +0100, "Martijn"
<su*********************@hot-remove-mail.com> wrote: Hi,
I think I can best ask my question by example. I may be overlooking something, but this is like what I have:
#define ID1 'i' #define ID2 'd' #define ID3 'n'
This is what I want in my output file:
i=100:d=200:n=300
This is what I do:
sprintf("%c=%d:%c=%d:%c=%d\n", ID1, 100, ID2, 200, ID3, 300);
That means that the characters are inserted run-time. Is there a way to make them part of the string-constant so that I can put them into my string compile-time?
If you change the defines to specify double quotes (") instead of
single quotes ('), then your format string can be coded as
ID1 "=%d:" ID2 "=%d:" ID3 "=%d\n"
since the compiler will automatically merge adjacent quoted strings
together.
<<Remove the del for email>> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Random Person |
last post by:
Does anyone know how to use VBA to relink tables between two MS Access
databases? We have two databases, one with VBA code and the other with
data tables. The tables are referenced by linked...
|
by: Grasshopper |
last post by:
Hi,
I am automating Access reports to PDF using PDF Writer 6.0. I've
created a DTS package to run the reports and schedule a job to run this
DTS package. If I PC Anywhere into the server on...
|
by: techno |
last post by:
Dear all,
Our bitmap has some x00 values ( '\0' ) and i am storing it in char*
array. the problem is that the '\0' is treated as eos character in c
and it is truncating it so the characters...
|
by: Angel |
last post by:
I'm trying to call a DLL function that receives as parameter a user-defined
structure created by the company that made the dll.
When I call the function from my main form, I call...
|
by: karthi |
last post by:
hi,
I need user defined function that converts string to float in c.
since the library function atof and strtod occupies large space in
my processor memory I can't use it in my code.
regards,...
|
by: cornedbeef007-groups |
last post by:
I have built a database for dog pedigrees.
I want to be able to display the siblings for a dog on it's pedigree. I
am able to find the names in my database, and at present return them
from a UDF...
|
by: Brand Bogard |
last post by:
Does the C standard include a library function to convert an 8 bit character
string to a 16 bit character string?
|
by: Rui Maciel |
last post by:
I've been delving into finite state machines and at this time it seems that
the best way to implement them is through an intense use of the goto
statement. Yet, everyone plus their granmother is...
|
by: gw7rib |
last post by:
I'm using a system in which TCHAR is typedef-ed to represent a
character, in this case a wchar_t to hold Unicode characters, and
LPCTSTR is typedef-ed to be a pointer to constant wchar_t. I presume...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |