Click here to Skip to main content
15,893,564 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Char * delete assertion failed Pin
Ash_VCPP13-Jul-09 4:04
Ash_VCPP13-Jul-09 4:04 
GeneralRe: Char * delete assertion failed Pin
«_Superman_»13-Jul-09 4:07
professional«_Superman_»13-Jul-09 4:07 
GeneralRe: Char * delete assertion failed Pin
David Crow13-Jul-09 4:37
David Crow13-Jul-09 4:37 
AnswerRe: Char * delete assertion failed Pin
Stuart Dootson13-Jul-09 6:47
professionalStuart Dootson13-Jul-09 6:47 
QuestionC++ program to print the path without the file name! Pin
ksaw12313-Jul-09 3:02
ksaw12313-Jul-09 3:02 
AnswerRe: C++ program to print the path without the file name! Pin
chandu00413-Jul-09 3:14
chandu00413-Jul-09 3:14 
GeneralRe: C++ program to print the path without the file name! Pin
ksaw12313-Jul-09 10:04
ksaw12313-Jul-09 10:04 
GeneralRe: C++ program to print the path without the file name! Pin
chandu00413-Jul-09 17:01
chandu00413-Jul-09 17:01 
this logic worked for me perfectly.
const char * path = "/work1/data/xxxx/yyy/file_name.txt";
char path1[256];
strcpy(path1,path);//copying the char array
cout << path <<"\n";//this prints the whole filename with path.
int l=strlen(path);//finding the length of the path
for(int i=l;i>0;i--)//reverse traversing the array
{
    if(path1[i]=='/')//if '/' is found, then replacing it with '\0'.
    {
        path1[i]='\0';
        break;
    }
}
cout << path1<<"\n";//this prints only the path.

the output is as you desired.

--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.

GeneralRe: C++ program to print the path without the file name! Pin
ksaw12313-Jul-09 21:19
ksaw12313-Jul-09 21:19 
GeneralRe: C++ program to print the path without the file name! Pin
chandu00413-Jul-09 21:24
chandu00413-Jul-09 21:24 
GeneralRe: C++ program to print the path without the file name! Pin
kilt15-Jul-09 5:42
kilt15-Jul-09 5:42 
AnswerRe: C++ program to print the path without the file name! Pin
Jijo.Raj13-Jul-09 3:14
Jijo.Raj13-Jul-09 3:14 
GeneralRe: C++ program to print the path without the file name! Pin
ksaw12313-Jul-09 10:06
ksaw12313-Jul-09 10:06 
GeneralRe: C++ program to print the path without the file name! Pin
David Crow13-Jul-09 10:12
David Crow13-Jul-09 10:12 
GeneralRe: C++ program to print the path without the file name! Pin
ksaw12313-Jul-09 10:37
ksaw12313-Jul-09 10:37 
GeneralRe: C++ program to print the path without the file name! Pin
David Crow13-Jul-09 10:39
David Crow13-Jul-09 10:39 
GeneralRe: C++ program to print the path without the file name! Pin
ksaw12313-Jul-09 10:59
ksaw12313-Jul-09 10:59 
GeneralRe: C++ program to print the path without the file name! Pin
David Crow13-Jul-09 16:59
David Crow13-Jul-09 16:59 
QuestionRe: C++ program to print the path without the file name! Pin
CPallini13-Jul-09 3:22
mveCPallini13-Jul-09 3:22 
AnswerRe: C++ program to print the path without the file name! Pin
ksaw12313-Jul-09 10:08
ksaw12313-Jul-09 10:08 
GeneralRe: C++ program to print the path without the file name! Pin
CPallini13-Jul-09 12:09
mveCPallini13-Jul-09 12:09 
GeneralRe: C++ program to print the path without the file name! Pin
ksaw12313-Jul-09 12:54
ksaw12313-Jul-09 12:54 
GeneralRe: C++ program to print the path without the file name! Pin
chandu00413-Jul-09 17:16
chandu00413-Jul-09 17:16 
GeneralRe: C++ program to print the path without the file name! Pin
CPallini13-Jul-09 21:49
mveCPallini13-Jul-09 21:49 
QuestionWhy would this cause a class destruction crashed? Pin
transoft13-Jul-09 2:51
transoft13-Jul-09 2:51 

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.