Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84 (Fortune 01.1b1); site graffiti.UUCP
Path: utzoo!linus!philabs!cmcl2!seismo!ut-sally!ut-ngp!shell!graffiti!bruce
From: bruce@graffiti.UUCP (Bruce Jilek)
Newsgroups: net.lang.c
Subject: What is wrong with this program?
Message-ID: <117@graffiti.UUCP>
Date: Thu, 8-Aug-85 00:28:19 EDT
Article-I.D.: graffiti.117
Posted: Thu Aug  8 00:28:19 1985
Date-Received: Mon, 12-Aug-85 02:12:59 EDT
Distribution: net
Organization: Information Brokerage Network, Houston, TX
Lines: 53

Why does printf insist that data->ut_line is a null string while
putchar can display all of the characters of this array?

Sorry if this is a trivial question, but it beats the hell 
out of me.  (If it helps, this is on a Fortune 32:16 - sort of v7.)


/****************************************************************
    This program is a rough imitation of "who /usr/adm/wtmp".
****************************************************************/
#include 

main()
{

	struct utmp {    /* This structure is straight out of utmp.h */
		char	ut_line[8];		/* tty name */
		char	ut_name[8];		/* user id */
		long	ut_time;		/* time on */
	};

	FILE *f;
	int i;
	struct utmp *data;
	if (f = fopen ("/usr/adm/wtmp", "r")) {
		while ((fread (data, sizeof(struct utmp), 1, f))  >  0) {
			putchar('\t');
			for (i = 0; i <= 7; i++) {
				putchar(data->ut_line[i]);
			}
			printf("\n");
			printf("%s	%s	%ld\n", data->ut_name,
				data->ut_line, data->ut_time);
		}
		fclose(f);
	}
}

/**********************************************************************
  End of program
**********************************************************************/

Sample output:
	
	tty03                 /*  This shows that data->ut_line isn't null */
bruce	(null)	492299400     /*  So what's the problem in this line?      */
	tty03
	(null)	492299405
	tty02
mike	(null)	492299409
        .
        .
        .