How can I create an array of char with new? 
Author Message
 How can I create an array of char with new?

I need to create an array of char, and I type a statement like this:

char *meta = new char[500];

but it seems like "new" only can to allocate 256 bytes of memory or less,
because, when I execution that statement, "meta" only can hold 256
charactes, like if I write something like this:

char *meta = new char[256];

I really need to create an array with more than 256 characters, and I would
thank a lot if somebody gives me any kind of help.



Sat, 23 Jul 2005 23:31:27 GMT  
 How can I create an array of char with new?

Quote:
>I need to create an array of char, and I type a statement like this:

>char *meta = new char[500];

>but it seems like "new" only can to allocate 256 bytes of memory or less,
>because, when I execution that statement, "meta" only can hold 256
>charactes

Ren,

There's no such limitation - what you're seeing must be a consequence
of something else in your program that you've not shown us.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



Sat, 23 Jul 2005 23:58:51 GMT  
 How can I create an array of char with new?
I need to create an array of char, and I type a statement like this:

char *meta = new char[500];

but it seems like "new" only can to allocate 256 bytes of memory or less,
because, when I execution that statement, "meta" only can hold 256
charactes, like if I write something like this:

char *meta = new char[256];

I really need to create an array with more than 256 characters, and I would
thank a lot if somebody gives me any kind of help.



Sun, 24 Jul 2005 03:54:08 GMT  
 How can I create an array of char with new?

Quote:

> I need to create an array of char, and I type a statement like this:

> char *meta = new char[500];

> but it seems like "new" only can to allocate 256 bytes of memory or less,
> because, when I execution that statement, "meta" only can hold 256
> charactes [...]

  What makes you think 'meta' can only hold 256 items?

  Schobi

--

I'm Schobi at suespammers org



Sun, 24 Jul 2005 05:15:45 GMT  
 How can I create an array of char with new?
Just try this to show it will hold more than 256 char:
for (int i=0;i<500;i++)
{
        meta[i] = 'x';

Quote:
}



Quote:

>> I need to create an array of char, and I type a statement like this:

>> char *meta = new char[500];

>> but it seems like "new" only can to allocate 256 bytes of memory or less,
>> because, when I execution that statement, "meta" only can hold 256
>> charactes [...]

>  What makes you think 'meta' can only hold 256 items?

>  Schobi



Sat, 27 Aug 2005 00:47:07 GMT  
 How can I create an array of char with new?

Quote:
> Just try this to show it will hold more than 256 char:
> for (int i=0;i<500;i++)
> {
> meta[i] = 'x';
> }



> [...]
> >  What makes you think 'meta' can only hold 256 items?
> [...]

  Tried this:

  #include <iostream>

  int main(int argc, char* argv[])
  {
    char *meta = new char[500];

    for (int i=0;i<500;i++)
    {
      meta[i] = 'x';
    }
    meta[500] = '\0';

    std::cout << meta << std::endl;

    return 0;
  }

  Prints more than four lines on a 80 char wide
  command window.

  Schobi

--

I'm Schobi at suespammers dot org



Sat, 27 Aug 2005 08:15:50 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Differences between char array[SIZE] and char *array

2. Converting char array of literals chars to escape chars

3. A char pointer (char *) vs. char array question

4. Creating a new char variable on the heap

5. new char[] array help

6. new char[] array help

7. Create a stream from an umanged char array

8. help with function to create dynamic two-dimensional char array

9. Creating a .bmp file from a char array

10. char array (array of array...) question

11. How can i change a array in function (without creating a new one)

12. create a new array each time in a loop

 

 
Powered by phpBB® Forum Software