| |

VerySource

 Forgot password?
 Register
Search
View: 3422|Reply: 12

How many bytes does each element of an integer array take? Two or four? I didn't find the book

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-21 11:30:01
| Show all posts |Read mode
Thank you very much for replying
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-30 02:15:01
| Show all posts
carried out:
printf("%d\n",sizeof(int));
You know
Reply

Use magic Report

0

Threads

9

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-7-1 14:15:02
| Show all posts
4
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-7-10 23:30:01
| Show all posts
Looking at the compiler, tc defaults to short int: 2byte, vc is long int: 4byte
So it is best to use sizeof for dynamic allocation
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-7-12 00:30:01
| Show all posts
I execute the following statement, prompting% error. I use tc, so each element in the two-dimensional array occupies 2 bytes?
printf("%d\n",sizeof(int));
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-8-22 13:15:02
| Show all posts
Different on different platforms
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-22 13:30:01
| Show all posts
printf("%d\n",sizeof(int));
There is nothing wrong with this. What's wrong, post it and see
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-8-22 13:45:01
| Show all posts
Most compilers under DOS are 2, and under windows, most compilers are 4.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Asia/Pacific Region

Post time: 2020-8-23 07:00:01
| Show all posts
It is not only related to the operating system or machine, but also to the language.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-23 11:00:01
| Show all posts
There are 4 bytes in VC++ and two in C language
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