Jump to content
xisto Community

CaptainCPS-X

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. Hi there im new around here ^^, my original language is spanish so sorry for any wrong word i use,... Im working on some features for my program to load a Favorite games list from a text file but the problem I have is not parsing the file, is processing a string and spliting it into 3 variables, then I will use them to insert as items in a List View control, I just dont know what is wrong in the following code... //------------------------------------------------------------ TCHAR* pszRomname = NULL; TCHAR* pszTitle= NULL; TCHAR* pszHardware = NULL; char romname[256] = ""; char title[256] = ""; char hardware[256] = ""; int i = 0; char str[] = "mslug:Metal Slug Super Vehicle-001:Neo-Geo,"; char *pch; pch = strtok(str,":"); while(pch != NULL) { if(i == 0) { sprintf(romname,"%s",pch); } if(i == 1) { sprintf(title,"%s",pch); } if(i == 2) { sprintf(hardware,"%s",pch); } pch = strtok(NULL,":"); i++; } _stprintf(pszRomname, L"%s", romname); _stprintf(pszTitle, L"%s", title); _stprintf(pszHardware, L"%s", hardware); //------------------------------------------------------------ The app crashes with this code, maybe is because im converting the strings in a wrong way or something, I need them at the end like TCHARs and not 'char' that's why i use the _stprintf()... oh, btw if I remove this it will not crash but of course I need those strings to add the items in the List View control... _stprintf(pszRomname, L"%s", romname); _stprintf(pszTitle, L"%s", title); _stprintf(pszHardware, L"%s", hardware); ThanX in advance for any help, it will be really appreciated SeeYaa! ^^
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.