TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Roy Mcneill
from: Ara Gurjian
date: 1995-02-25 16:42:00
subject: help in `C`

I am new in C programming could some body help me.....
 1- To fix TAB key. What is the function to convert o's to transmit 
    spaces.
 2- What is the function to have the fixed field of characters
    eg Char to be 25.
 3- what is the function for my clock to work constently.

Please leave a meassage with the sample if you can...
OR call me 02 971-4771

Thanks in advance for your help. 
Regards
Ara
/*************************************************************
 *  Borland C++ ver 3.1                                      *
 *  Ara Gurjian    18 December 1994                          *
 *************************************************************/

#include    
#include    
#include    
#include    
#include        // For exit()
#include    
#include    

// Define the file pointers globally
FILE *stream;
void time(void);
void helpWin(void);
void textWin(void);
void textWin2(void);
void printNum(void);
void Quit(void);
void topWin(void);
main()
{
  int   ch;
  int   num=0;

  clrscr();

  // Opening a file on the same directory running the program.
  stream = fopen("DDAY.DAT", "w");
  if (!stream)
	{ puts("An error occurred while opening the file!");
	  exit(1); }

  // Code gets here if the file opened properly
  // and scanning the strings.

   topWin();
   helpWin();
   textWin();
   _setcursortype(_NOCURSOR);   //turn off cursor.
	 do {
		time();   //degital clock
		if( kbhit() ){
			ch = getch();
			switch( ch ) {
				case 27:             //Esc
					 Quit();
					 break;
				case '\r':                //Linefeed
					 break;
				case '\n':          //Newline
					 break;
				case '\t':          //Tab
					 break;
					default:
					 num++;
						textcolor(WHITE);
						printNum();
							textbackground(BLUE);
							textcolor (WHITE);
							cprintf("%d",num);
							textcolor (YELLOW);
							textbackground(BLACK);
						textWin2();
						while (ch != '\r' && ch != '\n') {
								cprintf("%c", ch);
								fputc(ch, stream);
								ch = getch();
								}
							cputs("\r\n");
							fputc('\n', stream);
						}
				}
		}while (ch !=27);
  fclose(stream);
  return 0;
}

/*~~~~~~~~~~~~~~~~~~Define help color and window~~~~~~~~~~~~~~~~~~~*/
void helpWin(void)
	{
		window(1,1,80,25);
		textcolor(YELLOW);
		textbackground(BLUE);
		gotoxy(1,24);
		for (int j=1; j<=80; j++)
			{ cprintf(" "); }
		gotoxy(31,24);
		cprintf("Press Esc to Quit!");
		window(65,24,80,25);
		textbackground(BLUE);
		textcolor(WHITE);
		cprintf("Forms:");
	}

/*~~~~~~~~~~~~~~~Define color and window for count No~~~~~~~~~~~~*/
void printNum(void)
	{
		window(1,1,80,25);
		textbackground(BLUE);
		gotoxy(72,24);
	}

/*~~~~~~~~~~~~~~~~~~Define first window text~~~~~~~~~~~~~~~~~~~*/
void textWin(void)
	{
		window(1,4,80,23 );
		textcolor(YELLOW);
		textbackground(BLACK);
	}

/*~~~~~~~~~~~~~~~~~~Define second text window~~~~~~~~~~~~~~~~~~~*/
void textWin2(void)
	{
	   window(1,4,80,23 );
	   insline();
		textcolor(YELLOW);
		textbackground(BLACK);
	}

/*~~~~~~~~~~~~~~~~~~Clear screen on exit~~~~~~~~~~~~~~~~~~~*/
void Quit(void)
	{
		window(1,1,80,25);
		textcolor(WHITE);
		textbackground(BLACK);
			clrscr();
	   _setcursortype(_NORMALCURSOR);   //normal cursor.
			exit(0);
	}

/*~~~~~~~~~~~~~~~~~Define box and window on top screen~~~~~~~~~~~~~~~*/
void topWin(void)
	{
	 int    height = 3,
			width = 80;
	 window( 1, 1, 80, 7);
	 textcolor(WHITE);
	 textbackground(BLUE);

	 for ( int line = 0, sch, ech, fch; linetm_hour < 12)        // set up extension
		if(t.ti_hour < 12)
			am_pm = "am";
	if (newtime -> tm_hour > 12)       // convert from 24-hour
		if(t.ti_hour > 12)         // to 12-hour clock
			t.ti_hour -= 12;
			newtime ->tm_hour -= 12;

	window( 3, 2, 80, 7);
	textcolor(RED);
	textbackground(CYAN);

		cprintf("%.10s %d  %02d:%02d:%02d %s", asctime(newtime),
						d.da_year,t.ti_hour,
						t.ti_min, t.ti_sec, am_pm );
 if (kbhit() == 0) goto loop1;   /* if no keys pressed, continue...   */
}



--- GEcho 1.11+
* Origin: Computropolis BBS * Sydney Australia * +61-2-545-0186 (3:712/407)
SEEN-BY: 50/99 54/54 620/243 623/630 711/401 409 410 430 510 807 808 809 932
SEEN-BY: 711/934 942 712/407 515 539 623 704 713/888 714/906 800/1 7877/2809
@PATH: 712/407 515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.