| |

VerySource

 Forgot password?
 Register
Search
View: 2091|Reply: 17

It is not used as a parameter, you cannot use global variables, and you cannot use it as a return value. How to use this

[Copy link]

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 Unknown

Post time: 2020-2-8 14:30:01
| Show all posts |Read mode
That's it. This is the structure to be used
typedef struct
{
char name [256]; // filename
uint32_t size; // file size
uint8_t * buffer; // buffer
uint8_t ver; // version
} file_t;
My file open function has a file descriptor fd. The file open function is used for read and write operations. The file open function returns the file_t pointer as a parameter to the read and write function. How can the fd value in the file open function be used? Used in read and write functions? fd is not used as a parameter and cannot be used as a return value. If global variables are used, the value of fd in two consecutive files becomes the descriptor of the second file, which is not enough?
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-3-31 14:15:01
| Show all posts
Looks messy
Reply

Use magic Report

0

Threads

63

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-3-31 22:45:01
| Show all posts
You bull, write it in main
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-4-1 01:00:01
| Show all posts
Why can't you pass in parameters
Reply

Use magic Report

0

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-4-1 20:45:01
| Show all posts
It can only be said that it is a perverted request.
Reply

Use magic Report

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-4-2 13:15:01
| Show all posts
I can't help it? I don't want to do that either. But the requirement is that the function parameters and return value (that structure) cannot be changed. Everyone help
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-4-3 00:00:01
| Show all posts
Implement a global registry, open one, put it in, and then use the person to find it by name. . . --b
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-4-3 06:00:01
| Show all posts
What does it matter that the return value (that structure) cannot be tampered with?
Reply

Use magic Report

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-4-3 21:15:01
| Show all posts
Implement a global registry, open one, put it in, and then use the person to find it by name. . . --b
The registry is not needed, the system is linux.
What does it matter that the return value (that structure) cannot be tampered with?
This means that the file descriptor I want cannot be passed as a parameter to the next function to use this file description server.
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-4-4 11:15:01
| Show all posts
It's not that the "register" of the system is your own implementation of a "registration information table", such as through std :: map.

Will it be modified if you pass it? Then you can pass the value instead of the pointer. If you have to modify it, you ca n’t change the actual parameter.
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