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 2912
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: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
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...
| |