Hi Stu,
I don't quite understand the problem that you are trying to fix here. Is it the newline thing or having to re-enter the information that bothers you?
Anyway, if it is the newline problem, you can always use clrscr (to clear the screen and then re-display your message) or gotoxy (to reset the cursor position) functions in conio.h. However, I can't find their equivalents in VC++ standard library so you may try using the system function (like what I did in the codes below) or look for their Win32 API equvalents.
If it is having to re-enter the information that bothers you, you can always create a function that screens out the non-integers in the user inputs.
Since I am not sure what it is that you are trying to do, I have included both options in the codes below:with users having to re-enter the information and with the program screening out the non-integers. You can ONLY use EITHER one of them and NOT both of them. Comment out the one that you don't need.
Let me know if the code below solves your problem =) Additionally, it checks up to 50 characters of user inputs.
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
void main()
{
char buffer;
char input[50];//to store user inputs
int a=0, b=0;
bool isnumber=true;
while(a<50) //a<50 is to prevent buffer overflow
//you can change it to 'while(true)'
//if you care less about buffer overflow
{
printf("Enter a number: "

;
while((buffer=getchar())!='\n')//while character is not a newline
{
/****************************************************/
//use the following codes if you want users to re-enter
//the inputs if they enter non-integers
if(isalpha((int)buffer))//if input contains alphabets
isnumber=false; //it's not a number
input[a]=buffer;
a++;
/***************************************************/
/***************************************************/
/* Use the following codes if you want the program to
automatically filter user inputs for integers and
screen out the characters
DON'T FORGET TO COMMENT OUT THE ABOVE CODES IF YOU
DECIDE TO USE THE CODES BELOW.
if(isdigit((int)buffer))//only if inputs is integer
{
input[a]=buffer; //store the user inputs
a++;
}
/*****************************************/
}
if (isnumber==true)//if inputs contains all numbers
{
printf("Okay\n"

;
printf("You have entered "

;
while(b<a)//display inputs
{
printf("%c",input
);
b++;
}
printf("\n"
;
break;
}
else
{
isnumber=true;//reset the isnumber flag
a=0;//reset the a count
system("cls"
;//You can clear the entire screen
//or re-set the cursor position.
//You can use clrscr or gotoxy functions
//in conio.h, but I can't find their
//equivalents in standard VC++ library.
//You may want to look for their Win32 API
//equivalents
printf("Re-enter the number\n"
;
}
}
}