| |

VerySource

 Forgot password?
 Register
Search
View: 785|Reply: 3

Why can't WinTc recognize unsigned

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-2 16:20:01
| Show all posts |Read mode
#include "stdio.h"
#include "conio.h"

main ()
{
    unsigned int i;
    i = 32777;
    i = i + 1;
    printf ("the num:% d", i);
    getch ();
}
The above code runs as -32758, but I explicitly declare unsigned
I just learned c, ask everyone, thank you.
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-2 16:45:01
| Show all posts
The output format of printf should not be% d, it should be% u
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-2 19:21:01
| Show all posts
Unsigned number output type is% u
What you output as signed is of course the output of int itself
It's like outputting char from% d
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-3 19:45:02
| Show all posts
Positive solution on the second floor: the problem lies in %d
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list