小编piz*_*man的帖子

为什么printf只显示第一个字母?

首先,我有一个功能,我有unsigned char*类型存储的标志.例如,Unicode中每个符号Abcdef!?[65 0] [98 0] [99 0] [100 0] [101 0] [102 0] [33 0] [63 0]2个字节.

当我使用for(unsigned char i=0; i<17; i++) printf("%c", pointer[i]);一切正常时,它显示Abcdef!?.但是当我使用printf("%s" pointer);它时,它只给我,A而不是别的.你能告诉我为什么吗?

c unicode printf

3
推荐指数
1
解决办法
744
查看次数

如何在C中使用头文件中的C++函数?

我正在写论文,我在C代码中使用C++函数有问题.我搜索了解决方案,但我找到了很多,但无论如何都没有用.请再向我解释一下.

要快我有类似下面后gcc main.c -o main,我得到undefined reference to 'cppfun'

cpp.h:

#pragma once

#ifdef __cplusplus
 extern "C" {
#endi

    void cppfun();

#ifdef __cplusplus
 }
#endif
Run Code Online (Sandbox Code Playgroud)

cpp.cpp:

#include <stdio.h>
#include "cpp.h"

void cppfun()
{
    printf("cpp_fun");
}
Run Code Online (Sandbox Code Playgroud)

main.c中:

#include <stdio.h>
#indlude "cpp.h"

int main(int argc, char *argv[])
{
    cppfun();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c c++ program-entry-point header

1
推荐指数
1
解决办法
135
查看次数

标签 统计

c ×2

c++ ×1

header ×1

printf ×1

program-entry-point ×1

unicode ×1