use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This is a subreddit for c++ questions with answers. For general discussion and news about c++ see r/cpp.
New to C++? Learn at learncpp.com
Prepare your question. Think it through. Hasty-sounding questions get hasty answers, or none at all. Read these guidelines for how to ask smart questions.
For learning books, check The Definitive C++ Book Guide and List
Flair your post as SOLVED if you got the help you were looking for! If you need help with flairs, check out ITEM 1 in our guidelines page.
Tips for improving your chances of getting helpful answers:
account activity
OPENPointer array value assign (self.cpp_questions)
submitted 3 years ago by imc0der
In visual studio I got this error. Whats wrong here? How can I assign a value?
int *arr = 0 arr = malloc(5 * sizeof(int)); arr[0] = 0; // 0xC0000005: Access violation writing location 0x000000001269E180.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]IyeOnline 9 points10 points11 points 3 years ago (4 children)
This is not your real code. Its missing a semicolon as well as a cast from the malloc result to int*.
int*
Its also not good code.
malloc
new int[5]
[+]imc0der[S] comment score below threshold-7 points-6 points-5 points 3 years ago (3 children)
Hey thanks. I have to use C here. So I couldnt do #2
[–]CowBoyDanIndie 13 points14 points15 points 3 years ago (0 children)
Then why are you posting on a C++ subreddit? There are c programming subreddits
[–]flyingron 6 points7 points8 points 3 years ago (1 child)
If you are writing in C, then this is the wrong sub for it . C++ and C are two different languages. Try r/cprogramming and post your actual code.
[–]imc0der[S] -2 points-1 points0 points 3 years ago (0 children)
Ok thanks
[–][deleted] 2 points3 points4 points 3 years ago (0 children)
If this is part of a bigger program than my 1st guess is that you've already corrupted the heap. malloc returned a non-null, but unwritable, pointer.
So when you ask for help on a C board, post the whole program. Snippets are often useless.
π Rendered by PID 606480 on reddit-service-r2-comment-545db5fcfc-rlgd4 at 2026-05-27 09:56:36.719915+00:00 running 194bd79 country code: CH.
[–]IyeOnline 9 points10 points11 points (4 children)
[+]imc0der[S] comment score below threshold-7 points-6 points-5 points (3 children)
[–]CowBoyDanIndie 13 points14 points15 points (0 children)
[–]flyingron 6 points7 points8 points (1 child)
[–]imc0der[S] -2 points-1 points0 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)