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

Question about concatenating quotation marks

I'm going to do something like this

#define INSPECT( FILENAME,) \
ofstream FILENAME("FILENAME.out");\

For example, I want "INSPECT(abc)" open a file with name "abc.out",
the file object's name is "abc".

I tried the following code, but it still doesn't work.
#define INSPECT( FILENAME,) \
ofstream FILENAME("##FILENAME.out##");\

Nov 14 '05 #1
3 1648
Hiho,
I'm going to do something like this

#define INSPECT( FILENAME,) \
ofstream FILENAME("FILENAME.out");\

For example, I want "INSPECT(abc)" open a file with name "abc.out",
the file object's name is "abc".

I tried the following code, but it still doesn't work.
#define INSPECT( FILENAME,) \
ofstream FILENAME("##FILENAME.out##");\


Last time I checked, ofstream was not in the C language...
So, this code will not compile, but the C preprocessor
will do what you want it to:

#define STRINGIZE(s) # s
#define XSTR(s) STRINGIZE(s)

#define INSPECT(file) \
ofstream (file)(XSTR(file) ".out")

int main (void)
{
INSPECT(test);

return 0;
}

Note: the string part becomes
"test" ".out"
which will be seen as "test.out" by the compiler.
The preprocessor output of
INSPECT(test);
is
ofstream (test)("test" ".out");
If the additional set of parentheses around test
gives you problems, then leave them out after understanding
what that means.
--Michael

Nov 14 '05 #2
Peng Yu <pe*******@gmail.com> wrote in message news:<fs********************************@4ax.com>. ..
I'm going to do something like this

#define INSPECT( FILENAME,) \
ofstream FILENAME("FILENAME.out");\

For example, I want "INSPECT(abc)" open a file with name "abc.out",
the file object's name is "abc".

I tried the following code, but it still doesn't work.
#define INSPECT( FILENAME,) \
ofstream FILENAME("##FILENAME.out##");\


Try

#define INSPECT(FILENAME) \
ofstream FILENAME(#FILENAME ".out")

During expansion, #FILENAME will be replaced with the value of
FILENAME surrounded by double quotes, which will be concatenated with
the ".out" string.

Example:

INSPECT(abc);

should expand to

ofstream abc("abc.out");
Nov 14 '05 #3
On Fri, 01 Oct 2004 09:41:55 -0500, in comp.lang.c , Peng Yu
<pe*******@gmail.com> wrote:
I'm going to do something like this
You need to explain what you're trying to do. The below doesn't make much
sense
#define INSPECT( FILENAME,) \
ofstream FILENAME("FILENAME.out");\


ofstream looks like C++. You're in the wrong group.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #4

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

Similar topics

6
by: calfliu | last post by:
hello: everybody! I have a simple question. How can I translate the selected value from art to recipient(hidden input button)? <form name="send" method="post" action="send.cgi"> <select...
8
by: Stephen Poley | last post by:
One disadvantage of using a simple text editor to produce HTML is that it is relatively time-consuming to put in the proper typographical quotation marks and dashes. A round tuit having arrived...
63
by: Tristan Miller | last post by:
Greetings. Do any popular browsers correctly support <q>, at least for Western languages? I've noticed that Mozilla uses the standard English double-quote character, ", regardless of the lang...
4
by: Thomas Miskiewicz | last post by:
Hi! Is using of a double quotation mark with a URL a problem? For example: http://myserver.com/query?field1=something&field2=test&params="field1=test1"+"field2=test2" Regards Thomas
1
by: Patty-O | last post by:
Good day, I'm very new to ASP and programming in general and I'm not sure if this is the correct place for this question so I offer my apologies in advance. I'm creating a press release page...
7
by: Paradigm | last post by:
I am trying to create a recordset where some text fields are matching. The problem is that some of the text fields contain quotation marks. I have tried to create the sql string using replace eg....
4
by: Mark Fox | last post by:
Hello, I've noticed in some sample code that sometimes people use the @ before a string when concatenating them. Example: string filePath = Appl.Request.PhysicalApplicationPath + @"bin\" +...
9
by: proctor | last post by:
hello, i hope this is the correct place... i have an issue with some regex code i wonder if you have any insight: ================ import re, sys
31
by: The Bicycling Guitarist | last post by:
Hi. For many years I have been using &quot; for double quotation marks in the HTML code, but the opening and closing quotation marks render the same in my browser. I'm considering going through and...
27
by: Mitch | last post by:
I'm brand new, and just started C# for Dummies. I've also put together a list of websites with code snippets and tutorials. If I cut-and-paste the following line from an example into Visual...
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: 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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.