Character array problem.

// I'm learning arrays todays and its going great so far. But I can't seem to under that how to use character in arrays. I made this simple array and its giving me declaration syntax error. Tell me what to do.

// Also tell me the best compiler you know of. I'm using Borland c++ at the moment. And it seems really buggy.

#include <iostream>
#include <conio>


int main()
{
char name[6] {'t','a','l','h','a','\0'};
cout<<[name];


getch();
}
Just a couple of syntax issues. You need to assign the array correctly and drop the brackets around the name on the cout statement.

1
2
3
4
5
6
7
8
9
#include <iostream>

int main( int argc, const char* argv[] )
{
    char name[6] = { 't', 'a', 'l', 'h', 'a', '\0' };
    std::cout << name;

    return 0;
}


For compiling, I usually use gcc. http://gcc.gnu.org/
Last edited on
Thanks.
Topic archived. No new replies allowed.