Article Index

Function to read in a number from standard input.

#include "project.h"

void GetNumber(COURSE* record)
{
	int i;                                                   //Declare incrementing variable

	printf("Please enter the course number: ");
	fgets(record -> number, 17, stdin);
	
	for(i = 0; i < 17; i++)                                  //Change new line to null and upcase string
	{
		record -> number[i] = toupper(record -> number[i]);
		if(record -> number[i] == '\n')
			record -> number[i] = '\0';
	}
		

	return;
}
Log in to comment