strcpy_s在vs2013win运行问题。
#include<stdio.h>#include<string.h>
#define WORDS "beast"
#define SIZE 40
int main()
{
char *orig = WORDS;
char copy[SIZE] = "Be the best that you can be.";
char *ps;
puts(orig);
puts(copy);
ps = strcpy_s(copy+7, orig);
puts(copy);
puts(ps);
return 0;
}
#include<stdio.h>
#include<string.h>
#define LIM 5
#define SIZE 40
int main()
{
char qwords[LIM][SIZE];
char temp[SIZE];
int i = 0;
printf("Enter %d words beginning with q:\n", LIM);
while (i < LIM && gets_s(temp))
{
if (strncmp(temp,"q",1)!=0)
printf("%s doesn't begin with q!\n", temp);
else
{
strcpy_s(qwords[i], temp);//而这个strcpy_s则可以运行。
i++;
}
}
puts("Here are the words accepted : ");
for (i = 0; i < LIM; i++)
{
puts(qwords[i]);
}
return 0;
}
求大虾指点。
return 0;
}