您的位置:首页 > 编程语言 > C语言/C++

c语言 vs2013 安全检查

2015-04-07 19:52 274 查看
今天学习到了字符串和字符串函数

源码

#include <stdio.h>

//#define _CRT_SECURE_NO_WARNINGS

#define MSG "You must have many talents.Tell me some."//一个符号字符号常量

#define LIM 5

#define LINELEN 81

int main(void)

{

    char name[LINELEN];

    char talents[LINELEN];

    int i;

    const char m1[40] = "Limit yourself to one line's worth.";

    const char m2[] = "If you can't think of anything. fake it.";

    const char *m3 = "\nEnough about me - what's your name?";

    const char *mytal[LIM] = { "Adding numbers swiftly",

        "Multiplying accurately", "Stashing data",

        "Following instructions to the letter",

        "Understanding the C language" };

    printf("Hi! I'm Clyde the Computer.""I have many talents.\n");

    printf("Let me tell you some of them.\n");

    puts("What's were they? Ah, yes, here's a partial list.");

    for (i = 0; i < LIM; i++)

        puts(mytal[i]);

    puts(m3);

    gets(name);

    printf("Well, %s, %s\n", name, MSG);

    printf("%s\n%s\n", m1, m2);

    gets(talents);

    puts("Let's see if I've got that list:");

    puts(talents);

    printf("Thanks for the information, %s.\n", name);

    getchar();

    return 0;
}

这样的代码在VS2013中是错误的,必须加上#define _CRT_SECURE_NO_WARNINGS而且必须加在代码的最顶端 不然还是会报错。

今天看到一句话是一位教授说,对于一种编程语言当你敲了十万行有效执行代码的时候你才算精通了这门语言,三万行算是熟悉这门语言了,受教啊。还差的很远呢。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c语言 编程 计算机 vs