Click here to Skip to main content
15,888,286 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to Find out what was selected in Combo Box Pin
Hamid_RT9-Dec-07 6:25
Hamid_RT9-Dec-07 6:25 
AnswerRe: How to Find out what was selected in Combo Box Pin
Mark Salsbery9-Dec-07 7:09
Mark Salsbery9-Dec-07 7:09 
AnswerRe: How to Find out what was selected in Combo Box Pin
ddspliting10-Dec-07 6:53
ddspliting10-Dec-07 6:53 
GeneralFrom Mpeg-2 to Vob Pin
mjmim9-Dec-07 3:59
mjmim9-Dec-07 3:59 
Answerabout const member function Pin
clj198705039-Dec-07 1:07
clj198705039-Dec-07 1:07 
GeneralRe: about const member function Pin
super_ttd9-Dec-07 2:51
super_ttd9-Dec-07 2:51 
GeneralRe: about const member function Pin
Steen Krogsgaard9-Dec-07 22:29
Steen Krogsgaard9-Dec-07 22:29 
Questionproblem in code running on msvs2008 c++ while same logic runs fine on turbo c++ 3.0 Pin
ashjas8-Dec-07 23:27
ashjas8-Dec-07 23:27 
Hello,
I have run this logic on turboc++ 3.0 and it is working fine on it but
its not running on msvs2008 c++.

the code does this::
the fun strrep takes 3 char arrays the i.e main,sub,rep.
the sub array is to be found out i the main array and if found its index is taken on found pos,(this is achieved by the searchsub function separately)
then the sub array is replaced in the main array by the rep array,and the rep array can be of different size from the sub array.



i am not able to assign the value like this *temp=*main,where main and
temp are char pointers.

there is a runtime access violation error on msvs..that i am not
able to work out how to resolve..


kind attention and feedback would be invaluable for me...


thanks...the code is as below..


<code>// C++Test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream"

using namespace std;

int i;
int searchsub(char mainstr[],char fndstr[])
{
int mainlen=0,sublen=0,flag=-1,index=0;
for( i=0;mainstr[i]!='\0';i++)
mainlen++;
for( i=0;fndstr[i]!='\0';i++)
sublen++;
for(i=0;i<mainlen;i++)>
{
index=i;
if(mainstr[i]==fndstr[0])
{
for(int k=0;k<sublen;k++)>
{
if(mainstr[i++]!=fndstr[k])
{
flag=0;
break;
}
else flag=1;
}
if(flag==1)
break;
i=index;

}
}
if(flag==1)
return index;
else return -1;


}

char * strrep(char * main,char* sub,char* rep)
{
int sublen=0,mainlen=0,replen=0;
char* save=main;

char*temp;
for( i=0;*rep!='\0';i++,rep++)
replen++;
rep=rep-i;
int index=searchsub(main,sub);
for( i=0;*sub!='\0';i++,sub++)
sublen++;
sub=sub-i;
int reststrindex=index+sublen;
main=main+reststrindex;
for(i=0;*main!='\0';i++,temp++,main++)
*temp=*main;
*temp='\0';
main=main-i-reststrindex;
int templen=0;
temp=temp-i;
for( i=0;*temp!='\0';i++,temp++)
templen++;
temp=temp-i;
main=main+index;
for(i=index;i<index+replen;i++)>
{
*main=*rep;
main++;
rep++;
}
for(i=0;i<templen;i++)>
{
*main=*temp;
main++;
temp++;
}
*main='\0';
main=save;
return main;


}


int _tmain(int argc, _TCHAR* argv[])
{
cout&lt;&lt;strrep("Abcdefghijk","cde","peternorton");
return 0;
}</templen;i++)></index+replen;i++)></sublen;k++)></mainlen;i++)></code>
GeneralRe: problem in code running on msvs2008 c++ while same logic runs fine on turbo c++ 3.0 Pin
ashjas8-Dec-07 23:33
ashjas8-Dec-07 23:33 
GeneralRe: problem in code running on msvs2008 c++ while same logic runs fine on turbo c++ 3.0 Pin
normanS9-Dec-07 0:53
normanS9-Dec-07 0:53 
GeneralRe: problem in code running on msvs2008 c++ while same logic runs fine on turbo c++ 3.0 Pin
markkuk9-Dec-07 2:18
markkuk9-Dec-07 2:18 
GeneralRe: problem in code running on msvs2008 c++ while same logic runs fine on turbo c++ 3.0 Pin
ashjas9-Dec-07 4:15
ashjas9-Dec-07 4:15 
Questionfind error Pin
keyto8-Dec-07 20:08
keyto8-Dec-07 20:08 
GeneralRe: find error Pin
David Crow14-Mar-08 6:00
David Crow14-Mar-08 6:00 
GeneralDialogBox question Pin
KellyR8-Dec-07 8:47
KellyR8-Dec-07 8:47 
GeneralRe: DialogBox question Pin
Mark Salsbery8-Dec-07 9:25
Mark Salsbery8-Dec-07 9:25 
GeneralRe: DialogBox question Pin
KellyR8-Dec-07 9:37
KellyR8-Dec-07 9:37 
GeneralGDI+ trailing spaces and newline Pin
bob169728-Dec-07 5:59
bob169728-Dec-07 5:59 
GeneralWindow Styles Pin
Giorgi Dalakishvili8-Dec-07 4:32
mentorGiorgi Dalakishvili8-Dec-07 4:32 
GeneralRe: Window Styles Pin
Mark Salsbery8-Dec-07 6:23
Mark Salsbery8-Dec-07 6:23 
QuestionC++ resource file Pin
Somaiia7-Dec-07 21:44
Somaiia7-Dec-07 21:44 
GeneralRe: C++ resource file Pin
Mark Salsbery8-Dec-07 6:30
Mark Salsbery8-Dec-07 6:30 
QuestionDoes vs2008 support source control? How can vss for vc6 migrate to vs2008? Pin
followait7-Dec-07 16:34
followait7-Dec-07 16:34 
AnswerRe: Does vs2008 support source control? How can vss for vc6 migrate to vs2008? Pin
Christian Graus7-Dec-07 17:57
protectorChristian Graus7-Dec-07 17:57 
GeneralGetItemRect(iItem,&rt,LVIR_ICON), the result in rt is not accurate Pin
followait7-Dec-07 16:22
followait7-Dec-07 16:22 

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.