I am creating an array of char pointers.
char *str[2];
str[1]= "ma";
How ever the compiler gives me the following error. Any suggestions?
error: expected constructor, destructor, or type conversion before '='
token
error: expected `,' or `;' before '=' token 10 2918
On Mar 5, 10:34*am, Slain <Slai...@gmail.comwrote:
I am creating an array of char pointers.
char *str[2];
str[1]= "ma";
How ever the compiler gives me the following error. *Any suggestions?
error: expected constructor, destructor, or type conversion before '='
token
error: expected `,' or `;' before '=' token
I was mystified by this error too. So I tested it using Visual c++
and Windows XP with a std::cout statement std::cout<<str[1]; for
testing
I got the string ma as expected.
In other words, no this does not give any error on my machine. But
you've obviously posted a snippet rather than the full code because,
for example, there's no main. Could you please reproduce code in its
entirety which generates the error?
Paul Epstein
On Mar 4, 9:56 pm, pauldepst...@att.net wrote:
On Mar 5, 10:34 am, Slain <Slai...@gmail.comwrote:
I am creating an array of char pointers.
char *str[2];
str[1]= "ma";
How ever the compiler gives me the following error. Any suggestions?
error: expected constructor, destructor, or type conversion before '='
token
error: expected `,' or `;' before '=' token
I was mystified by this error too. So I tested it using Visual c++
and Windows XP with a std::cout statement std::cout<<str[1]; for
testing
I got the string ma as expected.
In other words, no this does not give any error on my machine. But
you've obviously posted a snippet rather than the full code because,
for example, there's no main. Could you please reproduce code in its
entirety which generates the error?
Paul Epstein
I am declaring this as a global variable outside main. I use this
later in a function
int x= size/ strlen(str);
for (int ii=0;ii<x; ii++)
{
strcat(String1,str);
}
On Mar 4, 9:56 pm, pauldepst...@att.net wrote:
On Mar 5, 10:34 am, Slain <Slai...@gmail.comwrote:
I am creating an array of char pointers.
char *str[2];
str[1]= "ma";
How ever the compiler gives me the following error. Any suggestions?
error: expected constructor, destructor, or type conversion before '='
token
error: expected `,' or `;' before '=' token
I was mystified by this error too. So I tested it using Visual c++
and Windows XP with a std::cout statement std::cout<<str[1]; for
testing
I got the string ma as expected.
In other words, no this does not give any error on my machine. But
you've obviously posted a snippet rather than the full code because,
for example, there's no main. Could you please reproduce code in its
entirety which generates the error?
Paul Epstein
I am declaring this as a global variable outside main. I use this
later in a function
int x= size/ strlen(str);
for (int ii=0;ii<x; ii++)
{
strcat(String1,str);
}
On Mar 4, 9:56 pm, pauldepst...@att.net wrote:
On Mar 5, 10:34 am, Slain <Slai...@gmail.comwrote:
I am creating an array of char pointers.
char *str[2];
str[1]= "ma";
How ever the compiler gives me the following error. Any suggestions?
error: expected constructor, destructor, or type conversion before '='
token
error: expected `,' or `;' before '=' token
I was mystified by this error too. So I tested it using Visual c++
and Windows XP with a std::cout statement std::cout<<str[1]; for
testing
I got the string ma as expected.
In other words, no this does not give any error on my machine. But
you've obviously posted a snippet rather than the full code because,
for example, there's no main. Could you please reproduce code in its
entirety which generates the error?
Paul Epstein
I am declaring this as a global variable outside main. I use this
later in a function
int x= size/ strlen(str);
for (int ii=0;ii<x; ii++)
{
strcat(String1,str);
}
On Mar 5, 11:02*am, Slain <Slai...@gmail.comwrote:
On Mar 4, 9:56 pm, pauldepst...@att.net wrote:
On Mar 5, 10:34 am, Slain <Slai...@gmail.comwrote:
I am creating an array of char pointers.
char *str[2];
str[1]= "ma";
How ever the compiler gives me the following error. *Any suggestions?
error: expected constructor, destructor, or type conversion before '='
token
error: expected `,' or `;' before '=' token
I was mystified by this error too. *So I tested it using Visual c++
and Windows XP with a std::cout statement *std::cout<<str[1]; for
testing
I got the string ma as expected.
In other words, no this does not give any error on my machine. *But
you've obviously posted a snippet rather than the full code because,
for example, there's no main. *Could you please reproduce code in its
entirety which generates the error?
Paul Epstein
I am declaring this as a global variable outside main. I use this
later in a function
int x= size/ *strlen(str);
* * * * for (int ii=0;ii<x; ii++)
* * * * {
* * * * * * * * *strcat(String1,str);
* * * * }- Hide quoted text -
- Show quoted text -
strlen(str) doesn't make sense to me. strlen means stringlength but
str is not a string as you've defined it. I have no idea what you
mean by strlen(str);
Paul Epstein
On Mar 4, 10:31 pm, pauldepst...@att.net wrote:
On Mar 5, 11:02 am, Slain <Slai...@gmail.comwrote:
On Mar 4, 9:56 pm, pauldepst...@att.net wrote:
On Mar 5, 10:34 am, Slain <Slai...@gmail.comwrote:
I am creating an array of char pointers.
char *str[2];
str[1]= "ma";
How ever the compiler gives me the following error. Any suggestions?
error: expected constructor, destructor, or type conversion before '='
token
error: expected `,' or `;' before '=' token
I was mystified by this error too. So I tested it using Visual c++
and Windows XP with a std::cout statement std::cout<<str[1]; for
testing
I got the string ma as expected.
In other words, no this does not give any error on my machine. But
you've obviously posted a snippet rather than the full code because,
for example, there's no main. Could you please reproduce code in its
entirety which generates the error?
Paul Epstein
I am declaring this as a global variable outside main. I use this
later in a function
int x= size/ strlen(str);
for (int ii=0;ii<x; ii++)
{
strcat(String1,str);
}- Hide quoted text -
- Show quoted text -
strlen(str) doesn't make sense to me. strlen means stringlength but
str is not a string as you've defined it. I have no idea what you
mean by strlen(str);
Paul Epstein
Yes!!! That part of the code was before I tried to make str an array
if pointers. When I used the strlen I just used the str as a char
pointer.
Thanks
manny
Slain wrote:
>
Yes!!! That part of the code was before I tried to make str an array
if pointers. When I used the strlen I just used the str as a char
pointer.
Is there a good reason why you can't use std::string?
--
Ian Collins.
On Mar 5, 11:34*am, Slain <Slai...@gmail.comwrote:
On Mar 4, 10:31 pm, pauldepst...@att.net wrote:
On Mar 5, 11:02 am, Slain <Slai...@gmail.comwrote:
On Mar 4, 9:56 pm, pauldepst...@att.net wrote:
On Mar 5, 10:34 am, Slain <Slai...@gmail.comwrote:
I am creating an array of char pointers.
char *str[2];
str[1]= "ma";
How ever the compiler gives me the following error. *Any suggestions?
error: expected constructor, destructor, or type conversion before'='
token
error: expected `,' or `;' before '=' token
I was mystified by this error too. *So I tested it using Visual c++
and Windows XP with a std::cout statement *std::cout<<str[1]; for
testing
I got the string ma as expected.
In other words, no this does not give any error on my machine. *But
you've obviously posted a snippet rather than the full code because,
for example, there's no main. *Could you please reproduce code in its
entirety which generates the error?
Paul Epstein
I am declaring this as a global variable outside main. I use this
later in a function
int x= size/ *strlen(str);
* * * * for (int ii=0;ii<x; ii++)
* * * * {
* * * * * * * * *strcat(String1,str);
* * * * }- Hide quoted text -
- Show quoted text -
strlen(str) *doesn't make sense to me. *strlen means stringlength but
str is not a string as you've defined it. *I have no idea what you
mean by strlen(str);
Paul Epstein
Yes!!! That part of the code was before I tried to make str an array
if pointers. When I used the strlen I just used the str as a char
pointer.
Thanks
manny- Hide quoted text -
- Show quoted text -
I don't understand why you say "Yes!!!" What question are you
answering "Yes!!!" to? It seems that "Yes!!!" should be replaced by
"Sorry for the confusion I caused."
Paul Epstein
On Mar 5, 7:34*am, Slain <Slai...@gmail.comwrote:
I am creating an array of char pointers.
char *str[2];
str[1]= "ma";
How ever the compiler gives me the following error. *Any suggestions?
error: expected constructor, destructor, or type conversion before '='
token
error: expected `,' or `;' before '=' token
you are not allocating memory for that.
faiz ul haque zeya
Transys
Slain dixit:
On Mar 4, 9:56 pm, pauldepst...@att.net wrote:
>On Mar 5, 10:34 am, Slain <Slai...@gmail.comwrote:
>>I am creating an array of char pointers. char *str[2]; str[1]= "ma"; How ever the compiler gives me the following error. Any suggestions? error: expected constructor, destructor, or type conversion before '=' token error: expected `,' or `;' before '=' token
I was mystified by this error too. So I tested it using Visual c++ and Windows XP with a std::cout statement std::cout<<str[1]; for testing I got the string ma as expected.
In other words, no this does not give any error on my machine. But you've obviously posted a snippet rather than the full code because, for example, there's no main. Could you please reproduce code in its entirety which generates the error?
Paul Epstein
I am declaring this as a global variable outside main. I use this
later in a function
If your code is like that:
char *str[2]; // line 1
str[1] = "ma"; // line 2
// ...
int main()
{
}
be aware that line 2 is illegal.
>
int x= size/ strlen(str);
for (int ii=0;ii<x; ii++)
{
strcat(String1,str);
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Krackers |
last post by:
How do you write a function which returns a reference to an array. I
can only get a function to return a copy of the array itself. I've had
a look at some other threads in this group an the return...
|
by: Robert |
last post by:
Hi,
This might be a strange question but i would like to know how to
return an array from a function. Do you have to use pointers for this?
Thanks in advance,
Robert
|
by: blue |
last post by:
Hi, all:
Recently I found this comment on comp.lang.c "Answers to FAQ" (6.13):
If you really need to declare a pointer to an entire array, use
something like "int (*ap);" where N is the size of...
|
by: cdg |
last post by:
Would anyone explain how to return an array that wasn`t passed from
"main" using a pointer. I'm not understanding how scope and memory are
involved in this.
However, I do know that there are two...
|
by: Michael |
last post by:
Hi,
I am trying to get an idea of how function pointers work.
I have the following:
#include <stdio.h>
void do_stuff(int*,int,void*);
void getInt(int*);
void showInt(int*);
|
by: Cliff Martin |
last post by:
Hi,
I am reading a fairly large file a line at a time, doing some
processing, and filtering out bits of the line. I am storing the
interesting information in a struct and then printing it out....
|
by: roguefeebo |
last post by:
I'm very new to programming so be gentle, :(
Essentially what I would like to do is to have a single function to be able to create a dynamic array of pointers to a struct so that I can have a...
|
by: Piotrek |
last post by:
Hi,
I have no idea why my reallocation function (myadd) is breaking up my
array. I'm trying to solve it and it took me few hours already. Maybe
you can look at my code and explain me what is...
|
by: Mike |
last post by:
I am using a COM DLL function that takes a pointer to the first
element in an array of short values.
Foo(short* array)
COM interop provides that function to me in the .NET world with a "ref...
|
by: alansharp |
last post by:
Hi guys
Im attempting to write conways Game of life and need to use a pointer and 2 arrays. The reason im using a pointer is hopefully to speed up the code rather than copying the array >...
|
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,...
|
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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:
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: 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,...
|
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,...
|
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...
| |