i made this to separate the string argument created from a drag and drop. but i'm not sure why the 'justpath' prints extra charactors after the path?. hope you see what i mean from the code. i tryed adding NULL thingy to the end but this didn't help.
Code:#include <stdio.h> main(argc,argv) int argc; char *argv[]; { int go,go2,pathlen; char *path,*filename,*extention,*justpath; path=(char*)malloc(60); filename=(char*)malloc(20); extention=(char*)malloc(10); pathlen=strlen(argv[1]); path=argv[1]; printf("value of [argv[0]]= %s\n",argv[0]); printf("value of [argv[1]]= %s\n",argv[1]); printf("amount of arguments[argc]= %d\n\n",argc); printf("path length= %d\n",pathlen); printf("name of [path]= %s\n",path); printf("starting address of [path]= %p\n",path); for(go=pathlen;path[go]!='.';go--){ printf("%d: to the dot [path[go]]= %c\n",go,path[go]); } for(go2=pathlen;path[go2]!='\\';go2--); strncpy(extention,path+go,5); printf("\n extention == %s\n",extention); printf("starting address of [exten]= %p\n",extention); strncpy(filename,path+go2,20); printf("\n filename == %s\n",filename); printf("starting address of [file]= %p\n",filename); strncpy(justpath,path,go2); //strcat(justpath,"\0"); printf("\n justpath == %s\n",justpath); printf("starting address of [justpath]= %p\n",justpath); return(0);}



LinkBack URL
About LinkBacks


