int num = "abc"; can't int be an integer?

Asked 2 weeks ago, Updated 2 weeks ago, 2 views

#include <stdio.h>
int main(void) 
{   

    int num = "abc";
    printf("%s\n", num);
    return 0;
}

Why isn't this working?

Is int not acceptable because it accepts an integer? So if you want to make it this similar way, what should you do? I still have a long way to go!

c

2022-09-20 08:58

1 Answers

int num = "abc";

Change the top line to the bottom line. Then it's going to print out.

const char* num = "abc";


2022-09-20 08:58

If you have any answers or tips


© 2022 pinfo. All rights reserved.