Greets, Janine.
> char Name[];
> Name[1]="J";
When creating an array, you need to specify the size. An exception is when
you're specifying the array elements alongside (or when you're allocating
memory dynamically, but that would be called a pointer, not an array).
Also, a char is represented using single-quotes. So "J" is wrong. 'J' is
right. When you use double-quotes, the compiler sees it as an array of
chars, terminated by a null chracter (\0).
So,
"foo"
is the same as
{'f', 'o', 'o', '\0' }
or
{'f', 'o', 'o', 0 }
In the above program, use
char Name[25]; // Some arbitrary size, otherwise, do char Name[] = "foo";
Name[1] = "J";
and it should work. One more thing - arrays begin at zero. I suspect that
here, you're trying to access the first element, in which case, it would be
Name[0].
HTH.
________________________________________
Abhijit Shylanath
http://mudeth.tripod.com/
|