Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7412779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:35:40+00:00 2026-05-29T06:35:40+00:00

How can I get rid of this error and other while compiling the below

  • 0

How can I get rid of this error and other while compiling the below code?

#include "stdafx.h"
#include <string>
#include <vector>
#include <windows.h>
#include <atlstr.h>
#include <tchar.h>
#include <stdio.h>
#define MAX_PATH_LENGTH 256 
int main(int argc, char *argv[])
{
  int i;
  char path[300];
  bool FindFilesFromFolder();
   getchar();
   return 0;
  } 

bool FindFilesFromFolder()

{
 HANDLE            hFile;
 WIN32_FIND_DATA   FindFileData;
 std::vector<char> fileList;

  char chFolderpath[_MAX_PATH];
  CString strExtension   = _T("*.B11");

  strcpy(chFolderpath, _T("F:\\test\\"));
  strcat(chFolderpath, strExtension);

 hFile = FindFirstFile(chFolderpath, &FindFileData);

  if (hFile == INVALID_HANDLE_VALUE) {

  AfxMessageBox(_T("Inavlid file handle."));
  return false;
  }

  CString filepath;

   do
   {

    filepath.Format(_T("%s%s"), _T("F:\\test\\"), FindFileData.cFileName);
    fileList.push_back(filepath);

   } while(FindNextFile(hFile, &FindFileData));


   return true;

  }

Yes this is an example to know the correct usage of findfirstfile(). I got strcpy errors too.

Error:error C2664: 'strcpy' : cannot convert parameter 2 from 'const wchar_t [9]' to 'const char *'. Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast.

Error: error C2664: 'strcat' : cannot convert parameter 2 from 'ATL::CString' to 'const char *'. No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called.

Error:error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'ATL::CString' to 'const char &' with

It gives all conversion errors; how to solve these errors?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:35:41+00:00Added an answer on May 29, 2026 at 6:35 am

    Your title says strcpy but your code and errors have FindFirstFile?

    Anyway, declaring your buffer like this will help:

    TCHAR chFolderpath[_MAX_PATH];
    

    Then you will want to use _tcscpy and _tcscat instead of strcpy and strcat. Even better, #include <strsafe.h> and use the string functions that protect against buffer overrun.

    Regarding AfxMessageBox, this is not a standard Windows function. It’s part of MFC, I suppose you cut and pasted from an example that used MFC. Windows has a MessageBox function which you can use, but you’ll need to supply all the parameters (parent window, message, title, buttons).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how I can get rid of the following assembler warning? Code
Other than turning warnings off.. what can I do in my code to get
How can I get rid of: <input type=hidden name=__VIEWSTATE id=__VIEWSTATE value=.../> Completely !
The black lines are awful, how can I get rid of them? I want
Can someone figure out how to get rid of the NOT EXISTS statements in
Logging can get complicated, quickly. Considering that you have some code, how do you
I know the < and > characters will cause this error, but what other
This actually corresponds to my other question but things get more complicated. I have
I have the following code String innerText = null; innerText = this.getException(detail.getChildElements()); causing this
Can get all triples with value null in specific field? All people with date_of_birth

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.