How to create a 256 character string buffer in Visual C ++?
  • one
    Can I be more specific? - skegg
  • char buf [256]; - sudo97

2 answers 2

Standard in C / C ++:

char buffer[256] = {0}; // 256 символов, включая завершающий нуль 

or (C ++):

 char *buffer = new char[256]; 

or (C):

 char *buffer = malloc(256); 
  • Probably, it means an array of strings (each element of the string type). - Yaroslav Schubert

On the stack:

 char a[257]; char* d=alloca(257); 

The memory is released automatically upon exiting the function.

In a heap:

 char* b=new char[257]; char* c=(char*)malloc(257); //... Используем //Не забываем освободить: delete[] b; free(c); 

Using the class std :: string:

 std::string str; str.reserve(256);