• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: problem with c code.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with c code.


  • Subject: Re: problem with c code.
  • From: Robert Tillyard <email@hidden>
  • Date: Mon, 28 Feb 2005 19:45:54 +0000

This was written in mail so hasn't been debugged or tested.

void create_logo_file( char * infilename)
{
char logo_name [512];
char logo_file_name [512];
char *p;

  // Remove path stuff.
  if ((p = strrchr (infilename, '//')) == (char *) 0L)
      p = infilename;

   strcpy (logo_name, p);
   strcpy (logo_file_name, p);

   // Remove .extn
   if ((p = strrchr (logo_file_name, '.')) != (char *) 0L)
	*p = '\0';

   // take on the "_logo.h"
   strcat (logo_file_name, "_logo.h");

   // need to return logo_file_name? you'll need to make it static
}

Regards, Rob.

On 28 Feb 2005, at 5:29 pm, D.Walsh wrote:

I'm looking for a quick solution, I'm passing partial filenames back and forth from argv[1] to other variables.

While making the project in XCode appears to work properly, compiling with gcc in terminal so it will build on any platforms is causing problems because finding all of the equivalent C functions is driving me nuts.

Basically what I need is this.

argv[1] holds the filename.

It's transfered to my routine with: (partial code listed)

#include <stdio.h>

void   create_logo_file    ( char * infilename);

main(int argc, char * argv[]) {
   char *prog_name=argv[0];

	if (argc !=2)  {
		printf("\n\t%s syntax:\n\n", argv[0]);
		printf("\t\t%s filename\n\n", argv[0]);
		exit(0);
	 }

	create_logo_file( argv[1] );
}
void create_logo_file( char * infilename) {
	char *logo_name;
	char *logo_file_name";
}
__________________________________________________


I need to remove all of the path info from argv[1] and store it in "logo_name" with ".gif" removed as well.


I need to transfer what is in "logo_name" with "_logo.h" appended and store it in "logo_file_name".

Needless to say, NSScanner is not an option since it wont compile on other OS's.

Anyone have any code that does this?

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >problem with c code. (From: "D.Walsh" <email@hidden>)

  • Prev by Date: Re: "distccsched" eating cpu, running hot
  • Next by Date: debugging question...
  • Previous by thread: problem with c code.
  • Next by thread: debugging question...
  • Index(es):
    • Date
    • Thread