Address instead of Strings ?!?

Can someone please tell me why this code is giving me the address instead of the strings?? I'm using dev c++. It compiles fine no problem, but instead of giving me the char strings, it gives me some wierd addresses in cyber space. Its kinda cool, but I'm not ammused at the moment.

----------------------------------------------------------

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream> 
#include <cwchar>
#define NNovelCount 4
using namespace std;

int Compare(const void* cvpWStr1, const void* cvpWStr2)
{
    return wcscmp((const wchar_t*) cvpWStr1, (const wchar_t*) cvpWStr2);
}

int main()
{
    //An array of novels by Ayn Rand
    wchar_t waaNovels[NNovelCount][20] = 
    {
            L"We the Living",
            L"Atlas Shrugged",
            L"The Fountainhead",
            L"Anthem"
    };
    
    //Sort the array using qsort()
    qsort(waaNovels, NNovelCount, 20*sizeof(wchar_t), Compare);
    for (int i = 0; i < NNovelCount + 1; ++ i)
    {
        cout << waaNovels[i] << endl;
    }
    
    char r;
    cin >> r;
    return 0;
}
   

-------------------------------------------------------------------

Here's two jpegs that show the original code and the output:

http://postimg.org/image/3x9757i8v/

http://postimg.org/image/7fxifoqfx/


Last edited on
Watch the asterisks, it represents a pointer. You probably have either one or two, maybe three misplaces asterisks somewhere in the program.
Print with wcout instead of cout.
http://www.cplusplus.com/reference/iostream/wcout/
I tried using wcout, but the program gives me a compiler error. is it because i'm using dev c++??
Probably. Update your compiler.
Post the compiler errors.
How do I update my compiler? Is there an update for Dev C++? I also have Visual Studio 2010, but I like Dev better at the moment cause it's smaller and easier.
You just need to download and install the latest MinGW.

Then, in Dev-C++'s options, find the stuff that locates the compiler, linker, etc, and include and library directories and change them to point to the new GCC's stuff.


That said, I actually recommend you just delete your existing Dev-C++ and download and install the latest Orwell Dev-C++. (It uses TDM-GCC, which is generally a better option, IMHO.)
http://sourceforge.net/projects/orwelldevcpp/
cool thanks. u rock man!
Topic archived. No new replies allowed.