473,379 Members | 1,367 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,379 software developers and data experts.

how to surround a constant with quotes?

lets say i do a

#define foo AbCdEf

now i want to do *something* that is NOT

#define foo2 "AbCdEf"

but has the same effect, ... so how can i tell the preprocessor "do me
some quotes around my foo-constant"?

-.rhavin;)

Mar 13 '07 #1
5 7782
..rhavin grobert said:
lets say i do a

#define foo AbCdEf

now i want to do *something* that is NOT

#define foo2 "AbCdEf"

but has the same effect, ... so how can i tell the preprocessor "do me
some quotes around my foo-constant"?
I'm not exactly sure which of the FAQs you're asking, but whichever one
it is, it's answered in Section 10 of the FAQ.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 13 '07 #2
On 13 Mar, 13:57, ".rhavin grobert" <c...@yahoo.dewrote:
lets say i do a

#define foo AbCdEf

now i want to do *something* that is NOT

#define foo2 "AbCdEf"

but has the same effect, ... so how can i tell the preprocessor "do me
some quotes around my foo-constant"?

-.rhavin;)
#define foo(x) #x
..
..
printf (foo(Put me some quotes around this\n));
..

Mar 13 '07 #3

..rhavin grobert wrote:
lets say i do a

#define foo AbCdEf

now i want to do *something* that is NOT

#define foo2 "AbCdEf"

but has the same effect, ... so how can i tell the preprocessor "do me
some quotes around my foo-constant"?
Yes.

#define foo(x) #x

What's wrong with the above solution for what you're trying to do?

Mar 13 '07 #4
..rhavin grobert wrote:
>
lets say i do a

#define foo AbCdEf

now i want to do *something* that is NOT

#define foo2 "AbCdEf"

but has the same effect, ... so how can i tell the preprocessor "do me
some quotes around my foo-constant"?
/* BEGIN new.c */

#include <stdio.h>

#define foo AbCdEf
#define str(x) # x
#define xstr(x) str(x)

int main(void)
{
puts(xstr(foo));
return 0;
}

/* END new.c */

--
pete
Mar 13 '07 #5
On Mar 14, 3:59 am, "santosh" <santosh....@gmail.comwrote:
.rhavin grobert wrote:
lets say i do a
#define foo AbCdEf
now i want to do *something* that is NOT
#define foo2 "AbCdEf"
but has the same effect,

#define foo(x) #x

What's wrong with the above solution for what you're trying to do?
Well, he would need to do it in several stages:
#define BAR(x) #x
#define BAZ(x) BAR(x)
#define foo2 BAZ(foo)

Mar 13 '07 #6

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

Similar topics

6
by: Jeff | last post by:
Hi, does anyone know why this: <a onclick="insertatcaret(window.opener.document.formname.fieldname,'<td class="header">')">text</a> returns a "Unterminated String Constant" error message in IE...
5
by: Joel | last post by:
Hi, I incorporated a function in my code that whenever I use a string variable in an sql statement if the string contains a single quote it will encase it in double quotes else single quotes. ...
2
by: Ja NE | last post by:
and new problem... buit this time I haven't found solution in some manual... problem: I would like to allow <a href="link"> tag, but I'm having problems in hidden field when checking message: ...
24
by: deko | last post by:
I'm trying to log error messages and sometimes (no telling when or where) the message contains a string with double quotes. Is there a way get the query to insert the string with the double...
4
by: vighnesh | last post by:
Hello EveryOne In my project I have to parse a string in Quotes as without Quotes.I tried the following code but it didn't work to me. I again getting the string with Quotes, Can Anybody suggest...
18
by: Andrew Backer | last post by:
Is it possible to embed a newline constant in a string in the same way as c#? I really don't want to do something like this: ++ String.Format("Line 1 : {0} " & vbcrlf & " Line 2 : {1}", o, t)...
5
by: qazwart | last post by:
I am reading from a "cvs rlog" command, and I need both the STDOUT and STDERR. Unfortunately, something very strange is happening. If I do this: $cmd = "$cvs_cmd -q rlog -NS...
2
by: SM | last post by:
Hello i have a constant define like this define('PHOTOGRAPHY', 'images/photography/'); The outpout (html) should look like this: <img src"images/photography/123.jpg"> How do i insert a...
14
by: adam.timberlake | last post by:
This is a really basic question for all you people out there who know PHP. This is not a problem but just something I'm confused about. I was reading the article below and wondered why are normal...
1
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.