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

Error while defining char array

Hi,

I have this code:

std::string::value_type * wh[] = {'\t'};

But it gives a compiler error, comlaining that it can't convert int to char.

What am I doing wrong?
Jul 22 '05 #1
6 1804
In article <rq********************************@4ax.com>,
Boogie El Aceitoso <fr****@telefonica.net> wrote:
I have this code:

std::string::value_type * wh[] = {'\t'};

But it gives a compiler error, comlaining that it can't convert int to char.

What am I doing wrong?


Bad diagnostic since the error is not in converting an int to a char
but in converting a char into a valuetype *. Should it just be a
valuetype?
--
Greg Comeau/4.3.3:Full C++03 core language + more Windows backends
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 22 '05 #2
On Wed, 03 Dec 2003 16:56:20 +0100, Boogie El Aceitoso
<fr****@telefonica.net> wrote:
Hi,

I have this code:

std::string::value_type * wh[] = {'\t'};

But it gives a compiler error, comlaining that it can't convert int to char.

What am I doing wrong?


Declaring an array of pointers-to-value-type. Try:

std::string::value_type wh[] = {'\t'};
Jul 22 '05 #3
Boogie El Aceitoso wrote:
Hi,

I have this code:

std::string::value_type * wh[] = {'\t'};

But it gives a compiler error, comlaining that it can't convert int to char.

What am I doing wrong?


Rewrite as:
std::string::value_type * wh[] = {"\t"};
or as:
std::string::value_type wh[] = {'\t'};

- Dario

Jul 22 '05 #4

"Dario" <da***@despammed.com> wrote in message
news:bq**********@fata.cs.interbusiness.it...
Boogie El Aceitoso wrote:
Hi,

I have this code:

std::string::value_type * wh[] = {'\t'};

But it gives a compiler error, comlaining that it can't convert int to char.
What am I doing wrong?


Rewrite as:
std::string::value_type * wh[] = {"\t"};
or as:
std::string::value_type wh[] = {'\t'};


Right, but I don't understand why OP is using string::value_type
anyway, since by definition it's 'char'.

char wh = '\t';

-Mike
Jul 22 '05 #5
In article <u8******************@newsread2.news.pas.earthlink .net>,
Mike Wahler <mk******@mkwahler.net> wrote:
"Dario" <da***@despammed.com> wrote in message
news:bq**********@fata.cs.interbusiness.it...
Boogie El Aceitoso wrote:
> std::string::value_type * wh[] = {'\t'};
>
> But it gives a compiler error, comlaining that it can't convert int to
> char.
>
> What am I doing wrong?


Rewrite as:
std::string::value_type * wh[] = {"\t"};
or as:
std::string::value_type wh[] = {'\t'};


Right, but I don't understand why OP is using string::value_type
anyway, since by definition it's 'char'.

char wh = '\t';


Probably the OP also has wchar_t's and maybe some other,
and wants to make that connection clear.
--
Greg Comeau/4.3.3:Full C++03 core language + more Windows backends
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 22 '05 #6

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:u8******************@newsread2.news.pas.earth link.net...

"Dario" <da***@despammed.com> wrote in message
news:bq**********@fata.cs.interbusiness.it...
Boogie El Aceitoso wrote:
Hi,

I have this code:

std::string::value_type * wh[] = {'\t'};

But it gives a compiler error, comlaining that it can't convert int to char.
What am I doing wrong?


Rewrite as:
std::string::value_type * wh[] = {"\t"};
or as:
std::string::value_type wh[] = {'\t'};


Right, but I don't understand why OP is using string::value_type
anyway, since by definition it's 'char'.

Probably just trying to get his head around it.
Jul 22 '05 #7

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

Similar topics

0
by: Morten Gulbrandsen | last post by:
mysql> USE company; Database changed mysql> mysql> DROP TABLE IF EXISTS EMPLOYEE; -------------- DROP TABLE IF EXISTS EMPLOYEE -------------- Query OK, 0 rows affected (0.00 sec)
7
by: Jacob Schmidt | last post by:
Could anyone correct the error in my logic here?: #include <stdio.h> #include <stdlib.h> main () { const char message1 = {"\nCurved portion of graph -- D.G.A.C.\ \n A B C"}; const char...
12
by: GRoll35 | last post by:
I get 4 of those errors. in the same spot. I'll show my parent class, child class, and my driver. All that is suppose to happen is the user enters data and it uses parent/child class to display...
0
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub)...
10
by: nambissan.nisha | last post by:
I am facing this problem.... I have to define a structure at runtime as the user specifies... The user will tell the number of fields,the actual fields...(maybe basic or array types or...
11
by: Andrew Poelstra | last post by:
I hammered this out this morning to fix inconsistancies with the way my programs handle errors. The code itself is fine, in that it compiles with Richard Heathfield's gcc tags (plus -c because it...
9
by: Gary Wessle | last post by:
Hi I am trying to understand how pthread is used, so I make the scenario below, I could not understand the erros by reading the man pthread_create. //**************** code start...
3
by: ZMan | last post by:
The following code won't compile with gcc version 3.4.2 (mingw-special). How come? Error: cannot convert `char (*)' to `char**' /**********************************************************/...
6
by: jma | last post by:
Hi all, I want to push some errors on an error stack in my function. The first parameter of the push function is the name of the function where the error occured. For example: int...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
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,...
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.