我想编写一个 Prolog 程序,将奇数列表中的中间元素删除到另一个列表中。
For example, If we give : delete_mid([1,2,3,4,5],L) then it will produce : L = [1,2,4,5] as answer.
每当我在用 C 进行编码时尝试使用 sprintf() 时,我都会收到一条警告:
\n\n\n“警告:\xe2\x80\x98%s\xe2\x80\x99 指令将最多 49 个字节写入大小\n39 [-Wformat-overflow=] 的区域”
\n
它还制作了一张纸条,上面写着:
\n\n\n"注意:\xe2\x80\x98sprintf\xe2\x80\x99 将 13 到 62 字节输出到大小为 50 62 的目标中 | sprintf(msg,"fopen-ing "%s"",data_file);"
\n
下面我给出了我的代码的一部分,主要是我收到此警告的地方。
\nchar data_file[50]; // Global\n\nvoid initialize_from_data_file()\n{\n FILE *fpS;\n if((fpS = fopen(data_file,"r")) == NULL)\n {\n char msg[50];\n sprintf(msg,"fopen-ing \\"%s\\"",data_file);\n perror(msg);\n exit(1);\n }\n ...\n}\nRun Code Online (Sandbox Code Playgroud)\n由于我最近使用这种语言,所以无法理解如何删除此警告。
\n