Re: [Dev-C++] char Array - DevC++ beginner...
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Mediatex <ma...@me...> - 2003-06-17 22:02:22
|
Create the array by specifying the required size in the square brackets:
e.g. char Name[12];
then put characters in the array like this:
Name[0]='J';
(use single quotes around the character and remember that array numbering
starts at 0)
or fill the array on creation, like this:
char Name[12]={"Janine"};
or use strcpy() , like this:
strcpy(Name, "Janine");
Good luck.
Kev.
-----------------------------------------------------------------------------------------------------
I am trying to create an array type char in Dev++ like this:
#include <iostream.h>
#include <stdlib.h>
#include <string>
int main()
{
char Name[];
Name[1]="J";
cout << sizeof(Name);
system("PAUSE");
return 0;
}
and DevC++ is telling me that the array size is missing and that assig to
"char" from "const char" lacks a cast.
Anyone could please help me with what I am doing wrong?
Thanks.
Janine
|