View Single Post
Old 2012-05-27, 20:58   #4
Basketry That Evening!
Dubslow's Avatar
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3·29·83 Posts

Try this on for size:
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

void strcopy(char* dest, char* src, size_t n) 
#ifdef _MSC_VER
	strcpy_s(dest, n, src);
	strncpy(dest, src, n);

int isprime(unsigned int n) //...etc
Turns out the Linux "safe" equivalent is strncpy, much like strncasecmp. It's too bad Microsoft can't just use the same damn function. (Note the different ordering of arguments, as well as the name.)

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
Attached Files
File Type: txt parse.c.txt (14.9 KB, 858 views)
Dubslow is offline   Reply With Quote