Closed. This question needs details or clarity。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?添加详细信息并通过editing this post阐明问题。
                        
                        5年前关闭。
                                                                                            
                
        
//program to display message using function as a parameter
#include<stdio.h>
#include<process.h>
//return name
char name_display(char *name)
{
    return *name;
}
//display name
void display(char (*display)(char *name1),char *name2)
{
    char name3;
    name3=display(name2);
    printf("name is %s",name3);
}
void main()
{
    display(name_display,"message");
}

最佳答案

当然:printf("name is %s",name3);想打印出一个字符串,但是name3只是一个char。可以像这样修复它:

printf("name is %c",name3);

或将您的代码修改为:

char* name_display(char *name)
{
    return name;
}
//display name
void display(char* (*display)(char *name1),char *name2)
{
    char* name3;


即:使用字符串而不是字符。

关于c - 它无法显示消息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25076028/

10-09 08:44