View Full Version : weird strings

07-03-2002, 05:28 PM
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.

#include <stdio.h>
int argc;
char *argv[];
int go,go2,pathlen;
char *path,*filename,*extention,*justpath;
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);
printf("%d: to the dot [path[go]]= %c\n",go,path[go]);


printf("\n extention == %s\n",extention);
printf("starting address of [exten]= %p\n",extention);

printf("\n filename == %s\n",filename);
printf("starting address of [file]= %p\n",filename);

printf("\n justpath == %s\n",justpath);
printf("starting address of [justpath]= %p\n",justpath);

07-04-2002, 01:35 PM
You'll have to be a bit more specific. What type of program is this, and what is this drag and drop program? If you know what the length of the string is, add a null character to the end based on that. Otherwise, with your current method, you could be placing the null after the extra characters. This would also be cause by have an array that wasn't initialized properly, or was initialized to be too big. What you should do is create a blank array first, and then filling it with the data. Make it blank by having every element contain \0, otherwise you'll end up with a bunch of characters that just depend on what was in memory last time it was used.

07-04-2002, 03:02 PM
its not really a program in its self but a function for a program. the main program just converts a files binary data into a format a C program can use. this works fine but you have to type the file name and its this i want to get rid of. i also want to use this data, location etc.. and transfer it to the output file.

07-05-2002, 09:59 AM
Again, you'll have to be more specific. First of all, what is the drag and drop for? What kind of program is this function for? Why are they typing the program path? Why do you want to get rid of it?

07-06-2002, 03:30 AM
while working on what you said in your first post i discovered i didn't allocate memory to the justpath variable. i'm sorry i was clear about the drag and drop i was on about how you can drag the file icon other the program icon and it would send the files path and name as a string to the second argument.
sorry to waste your time but what you've said has helped. thanks.

07-06-2002, 01:42 PM
lol - No problem. Glad I could help.