![]() |
![]() |
#1 | ||||
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
11100001101012 Posts |
![]() Quote:
Quote:
![]() Edit: http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx Quote:
Code:
bill@Gravemind:~/CUDALucas/test∰∂ cat parse.c #include <stdio.h> #include <string.h> #include <limits.h> #include <ctype.h> #include <errno.h> #include <stdlib.h> #ifdef _MSC_VER #define strncasecmp _strnicmp #define _CRT_SECURE_NO_WARNINGS #endif int isprime(unsigned int n) /* returns 0 if n is composite 1 if n is prime */ { unsigned int i; if(n<=1) return 0; if(n>2 && n%2==0)return 0; i=3; while(i*i <= n && i < 0x10000) { if(n%i==0)return 0; i+=2; } return 1; } Quote:
PS I forgot to mention above, but the help message was moved from no-args to the -h arg. PPS Here's a slightly larger .ini file: Code:
# Polite is the same as the -polite option. If it's 1, each iteration is # polite. If it's (for example) 12, then every 12th iteration is polite. Thus # the higher the number, the less polite the program is. Set to 0 to turn off # completely. Polite!=0 will incur a slight performance drop, but the screen # should be more responsive. Trade responsiveness for performance. (Note: # polite=0 is known to cause CUDALucas to use some extra CPU time; Polite=64 or # higher is a good compromise.) Polite=1 The attached archive contains the modified parse.c and CUDALucas.ini. |
||||
![]() |
![]() |
![]() |
#2 | |
Romulan Interpreter
"name field"
Jun 2011
Thailand
2·5,179 Posts |
![]() Quote:
|
|
![]() |
![]() |
![]() |
#3 | |
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3×29×83 Posts |
![]() Quote:
Last fiddled with by Dubslow on 2012-05-27 at 16:51 |
|
![]() |
![]() |
![]() |
#4 |
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
722110 Posts |
![]()
Try this on for size:
Code:
bill@Gravemind:~/CUDALucas/test∰∂ cat parse.c #include <stdio.h> #include <string.h> #include <limits.h> #include <ctype.h> #include <errno.h> #include <stdlib.h> #ifdef _MSC_VER #define strncasecmp _strnicmp #endif void strcopy(char* dest, char* src, size_t n) { #ifdef _MSC_VER strcpy_s(dest, n, src); #else strncpy(dest, src, n); #endif } int isprime(unsigned int n) //...etc Where it gave warnings, replace those "strcpy" calls with "strcopy", and add a third argument "MAX_LINE_LENGTH+1". Alternately, just DL the attached modified version ![]() |
![]() |
![]() |
![]() |
#5 |
"Jerry"
Nov 2011
Vancouver, WA
112310 Posts |
![]()
I'll work compiling tomorrow. I have to get some
![]() |
![]() |
![]() |
![]() |
#6 | |
Jun 2005
2018 Posts |
![]() Quote:
Last fiddled with by kjaget on 2012-05-30 at 14:34 |
|
![]() |
![]() |
![]() |
#7 |
Romulan Interpreter
"name field"
Jun 2011
Thailand
101000011101102 Posts |
![]() |
![]() |
![]() |
![]() |
#8 | |
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3·29·83 Posts |
![]() Quote:
Last fiddled with by Dubslow on 2012-05-30 at 19:50 |
|
![]() |
![]() |
![]() |
#9 | |
If I May
"Chris Halsall"
Sep 2002
Barbados
262348 Posts |
![]() Quote:
Code:
strncpy(dest, src, length); dest[length-1]=0; |
|
![]() |
![]() |
![]() |
#10 | ||
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3·29·83 Posts |
![]() Quote:
Quote:
Last fiddled with by Dubslow on 2012-05-30 at 20:06 Reason: It seems MSFT deserves credit for something they appear to have done better than on linux |
||
![]() |
![]() |
![]() |
#11 | |
If I May
"Chris Halsall"
Sep 2002
Barbados
22·5·571 Posts |
![]() Quote:
Code:
int strcpy_s( char *dest, int n, const char *src ) { if (!dest || !src) { return 1; // Stupid human... } if (strlen(src) > n-1) { return 2; // dest too small; Stupid human... } strncpy(dest, src, n); return 0; } |
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Official "new lows in Olympics TV coverage" thread | ewmayer | Soap Box | 15 | 2016-08-13 11:01 |
Official "Faits erronés dans de belles-lettres" thread | ewmayer | Lounge | 39 | 2015-05-19 01:08 |
Official "all-Greek-to-me Fiction Literature and Cinema" Thread | ewmayer | Science & Technology | 41 | 2014-04-16 11:54 |
Official "Lasciate ogne speranza" whinge-thread | cheesehead | Soap Box | 56 | 2013-06-29 01:42 |
Official "Ernst is a deceiving bully and George is a meanie" thread | cheesehead | Soap Box | 61 | 2013-06-11 04:30 |