Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

delbogun

Pointer = Array;

This topic is 5901 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have two variables which one of them is a global pointer and the other is a local array. char* global_pointer; char local_array[A_VALUE]; How do I save the value in local_array into global_pointer? I can''t just point the pointer on the array because the pointer is global and I need it outside. If local_array = "hello" then global_pointer = "hello".

Share this post


Link to post
Share on other sites
Advertisement
A pointer isn''t storage, it points to storage. Once the auto variable goes out of scope, so does the values it stores and then there''s nothing to point to. You can declare the local array static. That will give it global duration. Or you can declare the global variable as char (not char *) and then copy the auto variable value into the global eg. g_CharVar = local_array[A_VALUE];

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!