UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » emptying a string

#1 2009-03-23 03:36 PM

Ronin
Member
From: San Antonio, TX
Registered: 2009-03-09
Posts: 21

Re: emptying a string

It's me again!

How does one go about emptying a string?


"Science without religion is lame. Religion without science is blind."
-Albert Einstein

Offline

#2 2009-03-23 04:40 PM

jfriesne
Administrator
From: California
Registered: 2005-07-06
Posts: 348
Website

Re: emptying a string

Offline

#3 2009-03-23 05:12 PM

Ronin
Member
From: San Antonio, TX
Registered: 2009-03-09
Posts: 21

Re: emptying a string

char *getFilename( char *File ){

   int Answer = 0;

   do {
      printf("\nEnter file output name without extension: ");
      while (fgets (File, MAX_LEN, stdin)) {
         if (strlen(File) == (MAX_LEN-1) && File[MAX_LEN-2] != '\n'){
            DisplayErrorMsg(-5);
            fflush(stdin); [color=red] i know its not the prefered method but i'm at a loss[/color]
            break;
         } else { 
            sreplace('\0','\n', File);
            fprintf(stdout,"\nIs %s correct?[y/n] ",File);
            Answer = getAnswer();
            break;
         } 
      }
   } while (Answer == 0);
   return (File);
}

"Science without religion is lame. Religion without science is blind."
-Albert Einstein

Offline

#4 2009-03-23 06:01 PM

jfriesne
Administrator
From: California
Registered: 2005-07-06
Posts: 348
Website

Re: emptying a string

File[0] = '\0';

Offline

#5 2009-03-23 07:16 PM

Ronin
Member
From: San Antonio, TX
Registered: 2009-03-09
Posts: 21

Re: emptying a string

File[0] = '\0';

"Science without religion is lame. Religion without science is blind."
-Albert Einstein

Offline

#6 2009-03-23 08:39 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: emptying a string

Offline

#7 2009-03-24 01:38 PM

Ronin
Member
From: San Antonio, TX
Registered: 2009-03-09
Posts: 21

Re: emptying a string


"Science without religion is lame. Religion without science is blind."
-Albert Einstein

Offline

  • Index
  • » C
  • » emptying a string

Board footer

Powered by FluxBB