473,398 Members | 2,125 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,398 software developers and data experts.

comma in string

D
How do you put a comma in a string that's passed
as a function argument. The compiler thinks it's the
end of that argument and I've tried the /, and "," but
they don't seem to work.
Nov 14 '05 #1
6 1875

"D" <NoMail@NoSpam> wrote in message news:c0*********@enews1.newsguy.com...
How do you put a comma in a string that's passed
as a function argument. The compiler thinks it's the
end of that argument and I've tried the /, and "," but
they don't seem to work.


Um, printf("hello,world\n");

Will compile and execute just fine.

Tom
Nov 14 '05 #2
D
umm, I then suspect this may be an OS problem and not a C problem.
I getting a problem with the Windows MessageBox function, the
compiler is balking with the comma inside of the message string.
Nov 14 '05 #3
D <NoMail@nospam> scribbled the following:
umm, I then suspect this may be an OS problem and not a C problem.
I getting a problem with the Windows MessageBox function, the
compiler is balking with the comma inside of the message string.


It's most certainly an OS problem. In C, the comma has no special
meaning inside string literals, a comma is a comma is a comma.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"A bicycle cannot stand up by itself because it's two-tyred."
- Sky Text
Nov 14 '05 #4

"D" <NoMail@NoSpam> wrote in message news:c0*********@enews1.newsguy.com...
umm, I then suspect this may be an OS problem and not a C problem.
I getting a problem with the Windows MessageBox function, the
compiler is balking with the comma inside of the message string.

Check the preceding code, there may be an error there which leads to this.
Nov 14 '05 #5
nrk
Joona I Palaste wrote:
D <NoMail@nospam> scribbled the following:
umm, I then suspect this may be an OS problem and not a C problem.
I getting a problem with the Windows MessageBox function, the
compiler is balking with the comma inside of the message string.


It's most certainly an OS problem. In C, the comma has no special
meaning inside string literals, a comma is a comma is a comma.

It might also be a user problem. Perhaps OP hasn't escaped double quotes
inside the string or some such?

-nrk.
--
Remove devnull for email
Nov 14 '05 #6
D wrote:
How do you put a comma in a string that's passed
as a function argument. The compiler thinks it's the
end of that argument and I've tried the /, and "," but
they don't seem to work.


You'll have to show some code, since the behaviour you report is bizarre.
See what happens with the following code:

#include <stdio.h>

void showargs(const char *s, const char *t, int n)
{
printf("This function displays two string arguments,\n"
"followed by an integer one.\n"
"first string: \"%s\"\n"
"second string: \"%s\"\n" "the integer: %d\n", s, t, n);
}
int main(void)
{
showargs("This string has a comma (,) in it.",
"For that matter, so does this one.", 42);
return 0;
}
This function displays two string arguments,
followed by an integer one.
first string: "This string has a comma (,) in it."
second string: "For that matter, so does this one."
the integer: 42

--
Martin Ambuhl
Nov 14 '05 #7

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

Similar topics

27
by: Alberto Vera | last post by:
Hello: I have the next structure: How Can I make it using Python? How Can I update the value of 6?
4
by: Arne | last post by:
From: "Arne de Booij" <a_de_booij@hotmail.com> Subject: Comma delimited array into DB problems Date: 9. februar 2004 10:39 Hi, I have an asp page that takes input from a form on the previous...
3
by: Rakesh Sinha | last post by:
I have a very trivial question. But I searched in google / archives of this group to get the answer, checked the C++ FAQ - but did not precisely what I was looking for. The problem is with...
4
by: G Patel | last post by:
Hi, I've read a book on C, and I understand how comma operators work, but my book didn't say that the comma operators between function arguments were not really comma operators (even though it...
9
by: Wayne | last post by:
I have the following string: "smith", "Joe", "West Palm Beach, Fl." I need to split this string based on the commas, but as you see the city state contains a comma. String.split will spilt the...
2
by: JoeW | last post by:
Just wondering as I'm sure someone's done something similar to this before, I need to break up a string, broken up everytime a comma is come across. In example: A, B, C, D, E This can...
1
by: CJK | last post by:
this is what i have so far: #include <iostream> #include <string> #include <vector> #include <fstream> using namespace std; class Person {
17
by: mac | last post by:
Hi, I'm trying to write a fibonacci recursive function that will return the fibonacci string separated by comma. The problem sounds like this: ------------- Write a recursive function that...
13
by: mac | last post by:
Hi, I'm trying to write a fibonacci recursive function that will return the fibonacci string separated by comma. The problem sounds like this: ------------- Write a recursive function that...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
tracyyun
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.