[Libprime-devel-cvs] CVS: libprime/src/tests/prime-val prime-validator.cpp,1.1,1.2
Status: Inactive
Brought to you by:
simmo
|
From: Andrew S. <si...@us...> - 2001-12-08 13:55:03
|
Update of /cvsroot/libprime/libprime/src/tests/prime-val
In directory usw-pr-cvs1:/tmp/cvs-serv869/src/tests/prime-val
Modified Files:
prime-validator.cpp
Log Message:
working towards a 0.2 libprime release
Index: prime-validator.cpp
===================================================================
RCS file: /cvsroot/libprime/libprime/src/tests/prime-val/prime-validator.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- prime-validator.cpp 2001/12/06 08:56:57 1.1
+++ prime-validator.cpp 2001/12/08 13:54:57 1.2
@@ -1,7 +1,6 @@
/*
* libprime
- * prime-validator.cpp
- * Contributors: si...@ii...
+ * Copyright (c) 2001 Andrew Simmonds <si...@ii...>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -21,32 +20,24 @@
#include "libprime.h"
using namespace std;
-int main(int argc, char* argv[])
-{ //Is a certain prime real.
-
- cfloat version = static_cast<cfloat>(0.01);
- const string appname = "prime-validator";
+int main(int argc, char *argv[])
+{
+ if (argc != 2) {
+ cerr << "Not Enough Parameters\n";
+ return 0;
+ }
+
+ for (uint i = 1; i < strlen(argv[1]); i++) {
+ if (!isdigit(argv[1][i])) {
+ cerr << "Not a Number\n";
+ return 0;
+ }
+ }
- //TODO Process argv and argc for stuff!
+ ulong TestPrime = atol(argv[1]);
- cout << appname
- << " "
- << version
- << endl
- << endl;
+ bool answer = GetIsPrime(TestPrime);
- ulong TestPrime;
- cout << "Enter a number: ";
- cin >> TestPrime;
-
-
- bool answer = GetIsPrime(TestPrime);
-
- cout << endl
- << "Prime = "
- << (answer?"True":"False")
- << endl;
-
- return 0;
-
+ cout << (answer ? "True" : "False") << endl;
+ return 0;
}
|