Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8000901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:56:29+00:00 2026-06-04T15:56:29+00:00

IN the following C++ snippet, is a=b assigment possible ??: unsigned int * a;

  • 0

IN the following C++ snippet, is a=b assigment possible ??:

unsigned int * a;
D3DCOLOR b[16];
a=(unsigned int)b;

Will this assignment copy all the elements of b array to a? Is the typecast fine?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:56:31+00:00Added an answer on June 4, 2026 at 3:56 pm

    First of all, it should have been:

    a = (unsigned int *)b; // note the *
    

    More importantly, this just makes a point to contents of b, and it does not copy it. If you want to copy arrays, you have to do it explicitly, for example with a for loop or std::copy, that is if you don’t want to go with classes and stuff.

    Side note: to copy into a, you need memory for a! You can do it either on the stack:

    unsigned int a[16]; // 16 is an example
    

    or dynamically (for example with new).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Conditional operator assignment with Nullable<value> types? in the following code snippet company.ParentID
Take the following snippet: 1 #include <stdio.h> 2 #include <stdlib.h> 3 int foo(char [6]);
This question is inspired by this question , which features the following code snippet.
The following snippet of code creates 4 processes, all sharing the same listening socket.
The following snippet prints False : Console.WriteLine(Regex.IsMatch(abc, @[[:alpha:]])); But this prints True : Console.WriteLine(Regex.IsMatch(abc,
Examine the following snippet: assertThat( Arrays.asList(1x, 2x, 3x, 4z), not(hasItem(not(endsWith(x)))) ); This asserts that
The following snippet of C# code: int i = 1; string result = String.Format({0},{1},{2},
Here is my code snippet: int a; if(a=8) cout<<Its right; else cout<<Not at all;
The following snippet shows how I created my inheritance. I got inspired by this
Consider the following snippet env = Environment() env.PDF(target=personal_statement.pdf, source=personal_statement.tex) env.Command(documents/personal_statement.pdf, personal_statement.pdf, Copy('$TARGET', '$SOURCE')) If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.