This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

simple c question



hi!


i'm new to this list and i hope i'm not bothering you with this simple stuff:

i'm having problems with strings.

i want to get a path without filename into a string.

and the code is this:

/////////////////////////////////////////////////

// string.h included of course...

char * GetPath (char * string)
{
	char * path;
	int i, pos=-1;
	
	for(i=0;string[i]!=0;i++)
	{
		if(string[i]=='/')
			pos=i;
	}

	if(pos==-1)
		return NULL;
	
	strncpy(path, string, pos+1);
	
return path;
}

////////////////////////////////////////////

i don't get it to work.

can someone please help me?

thank you!

--
-----------------------------------------------
----------------maximilian marcoll-------------
-----------composition | performance-----------
http://icem-www.folkwang-hochschule.de/~marcoll
-----------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]