[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help me stay away from visual C++ :)



The more I think about it, the following is better.
No more buffer overflow problem.

#include <stdio.h>

int main()
{
  int test;
  int result;
  int j;

  for(j = 0; j < 10; j++)
  {
    while ( scanf("%*[^0-9-]") );

    result = scanf("%d", &test); 
    if ( ! result) 
	printf("Error\n");
    else
	printf("Success: %d\n", test);
  }
}

 



Reply to: