Click here to Skip to main content
15,913,941 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Crypto Acquire Contect - 80090019 Pin
izyani5-Nov-08 13:49
izyani5-Nov-08 13:49 
QuestionSave string inside an exe Pin
akshay.is.gr84-Nov-08 21:35
akshay.is.gr84-Nov-08 21:35 
AnswerRe: Save string inside an exe Pin
CPallini4-Nov-08 22:17
mveCPallini4-Nov-08 22:17 
QuestionHow to get selected file name prgramatically Pin
SNI4-Nov-08 21:30
SNI4-Nov-08 21:30 
AnswerRe: How to get selected file name prgramatically Pin
sashoalm5-Nov-08 0:10
sashoalm5-Nov-08 0:10 
GeneralRe: How to get selected file name prgramatically Pin
SNI5-Nov-08 17:57
SNI5-Nov-08 17:57 
GeneralRe: How to get selected file name prgramatically Pin
sashoalm6-Nov-08 3:19
sashoalm6-Nov-08 3:19 
QuestionERROR in _stricmp ..... prevent duplicate section names [modified] Pin
anna mathew4-Nov-08 21:25
anna mathew4-Nov-08 21:25 
Please help me.....

my sectionname is same as the name entered....

my code:

void CFileINIDlg::OnBnClickedInsert()
{

const CString szINIFILE = ("C:\\FileINI.ini");

//Accept name , address and phone no from edit box
m_Name.GetWindowText(Name);
m_Ad.GetWindowText(Address);
m_Phone.GetWindowText(Phoneno);

CT2A sectn = Name;
int cmp;
int cmpflag=0;
char message[4096];
strcpy (message, "Entries :\n\n"); //Initialize
LPTSTR lpszReturnBuffer;
lpszReturnBuffer = new TCHAR[MAX_PATH];
char* pNextSection = NULL;
GetPrivateProfileSectionNames(lpszReturnBuffer,MAX_PATH,szINIFILE);
pNextSection = lpszReturnBuffer;
strcat(message, pNextSection);
while (*pNextSection != NULL)
{
//to avoid overwriting entries with same section name
cmp = _stricmp(sectn, pNextSection);
if(cmp==0)
cmpflag= 1;
else
cmpflag=0;
pNextSection = pNextSection + strle(pNextSection) + 1;

if(*pNextSection != NULL)
{
strcat(message, "\n");
strcat(message, pNextSection);
}

}
sprintf(message,"%s\n CMP %d\n FLAG %d \n", message, cmp, cmpflag);
MessageBox(message);
if(cmpflag==1)
MessageBox("ERROR - DUPLICATE");
else if(cmpflag==0)
{
WritePrivateProfileString(Name, "Name", Name, szINIFILE);
WritePrivateProfileString(Name, "Address", Address, szINIFILE);
WritePrivateProfileString(Name, "Phone", Phoneno, szINIFILE);
}
}



Im writing the values entered to the INI file.....
I want to prevent overwritng an entry ...that has
the same section name.......

if sectionname is same....i reject the entries insertion to INI file...


my code compiles.....
but strcmp() is not working.....
it always returns 1.....

how do i correct it?

modified on Wednesday, November 5, 2008 3:35 AM

AnswerRe: ERROR in _stricmp ..... prevent duplicate section names Pin
Cedric Moonen4-Nov-08 21:31
Cedric Moonen4-Nov-08 21:31 
AnswerRe: ERROR in _stricmp ..... prevent duplicate section names Pin
CPallini4-Nov-08 22:02
mveCPallini4-Nov-08 22:02 
GeneralRe: ERROR in _stricmp ..... prevent duplicate section names Pin
anna mathew4-Nov-08 22:25
anna mathew4-Nov-08 22:25 
GeneralRe: ERROR in _stricmp ..... prevent duplicate section names Pin
CPallini4-Nov-08 22:32
mveCPallini4-Nov-08 22:32 
QuestionThreads in C++ Pin
yamaki3084-Nov-08 21:12
yamaki3084-Nov-08 21:12 
QuestionRe: Threads in C++ Pin
sashoalm4-Nov-08 23:35
sashoalm4-Nov-08 23:35 
AnswerRe: Threads in C++ Pin
yamaki3085-Nov-08 11:49
yamaki3085-Nov-08 11:49 
QuestionRe: Threads in C++ Pin
sashoalm6-Nov-08 7:55
sashoalm6-Nov-08 7:55 
QuestionHausdorff-Based Image Comparison Pin
kaushal kishore sharma4-Nov-08 21:09
kaushal kishore sharma4-Nov-08 21:09 
AnswerRe: Hausdorff-Based Image Comparison Pin
SandipG 4-Nov-08 21:12
SandipG 4-Nov-08 21:12 
QuestionWrite Text Pin
MsmVc4-Nov-08 21:03
MsmVc4-Nov-08 21:03 
AnswerRe: Write Text Pin
SandipG 4-Nov-08 21:10
SandipG 4-Nov-08 21:10 
QuestionReading data from a csv file in MFC c++ and displaying in excel format Pin
SeshaSridhar4-Nov-08 19:40
SeshaSridhar4-Nov-08 19:40 
AnswerRe: Reading data from a csv file in MFC c++ and displaying in excel format Pin
Saurabh.Garg4-Nov-08 19:58
Saurabh.Garg4-Nov-08 19:58 
AnswerRe: Reading data from a csv file in MFC c++ and displaying in excel format Pin
SeshaSridhar4-Nov-08 20:17
SeshaSridhar4-Nov-08 20:17 
GeneralRe: Reading data from a csv file in MFC c++ and displaying in excel format Pin
Hamid_RT4-Nov-08 20:37
Hamid_RT4-Nov-08 20:37 
AnswerRe: Reading data from a csv file in MFC c++ and displaying in excel format Pin
ThatsAlok4-Nov-08 20:02
ThatsAlok4-Nov-08 20:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.