subscript requires array or pointer ERROR

Posted by Kristian on Stack Overflow See other posts from Stack Overflow or by Kristian
Published on 2010-06-01T20:28:42Z Indexed on 2010/06/01 20:33 UTC
Read the original article Hit count: 207

Filed under:
|

Hi, I know what is my mistake can't figer how to solve it.

Im writing an winAPI that counts how many 'a' characters are found is a givien file. Im still getting the error " subscript requires array or pointer " (please find the comment in the code)

#include "stdafx.h"
#include <windows.h>


int _tmain(int argc, _TCHAR* argv[])
{
    WCHAR str=L'a';
    HANDLE A;
    TCHAR *fn;

    fn=L"d:\\test.txt";
    A= CreateFile(fn,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);

    if(A==INVALID_HANDLE_VALUE)
    {
        _tprintf(L"cannot open file \n");
    }

    else
    {
        DWORD really;
        int countletter;
        int stringsize;
        do
        {
            BYTE x[1024];


            ReadFile(A,x,1024,&really,NULL);
            stringsize = sizeof(really);
            for(int i =0;i<stringsize;i++)
            {

                if(really[i]==str)   //here Im getting the error
                    countletter++;
            }
        }while(really==1024);

            CloseHandle(A);
            _tprintf(L"NUmbers of A's found is %d \n",countletter);
    }

    return 0;
}

now I know I can't make comparesion between array and a WCHAR but hw to fix it ?

© Stack Overflow or respective owner

Related posts about c++

Related posts about winapi