Anshul
==30==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000244 at pc 0x00000034565f bp 0x7ffff9bb6c00 sp 0x7ffff9bb6bf8 READ of size 4 at 0x602000000244 thread T0 #2 0x7fe830cd20b2 (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) 0x602000000244 is located 16 bytes to the right of 4-byte region [0x602000000230,0x602000000234) allocated by thread T0 here: #6 0x7fe830cd20b2 (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) Shadow bytes around the buggy address: 0x0c047fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c047fff8000: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa 0x0c047fff8010: fa fa fd fd fa fa fd fa fa fa fd fa fa fa fd fa 0x0c047fff8020: fa fa fd fa fa fa fd fd fa fa fd fd fa fa fd fd 0x0c047fff8030: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fa =>0x0c047fff8040: fa fa fd fa fa fa 04 fa[fa]fa fd fa fa fa fd fa 0x0c047fff8050: fa fa 04 fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8090: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb Shadow gap: cc ==30==ABORTING
Anshul
can anyone explain what is this error?
Anshul
?
Anonymous
I'm not 100% sure but I think you tried to access a part of heap you didnt allocate
Anonymous
Probably you allocated some memory, started reading from the beginning and continued for too long
Anonymous
Or maybe you didnt even allocate the memory in the first place
Anonymous
Btw I think it's way better if you format your code/errors through pastebin or similar if it is long
Aniket
/get
Anonymous
Try to execute your program with valgrind on your sample test cases. Most probably there is memory leak.
+1 I think that if you compile with -static -s flags you can even get the line where you tried the invalid read
Anonymous
Anshul
Ok
Suka
/report
Manish Kumar
I am a beginner in c++ please suggest
Manish Kumar
How can I learn c++
Anonymous
Manish Kumar
Is there any notes forc or c++
Ram
Looking for lead iOS resource , with 8+ years of experience and good communication skills08:56
coolthought
Hi everyone. I have Google and trying to look for cloud based platform with compiler for C/C++ that is similar to colab. So that I can continue working seamlessly on different computer. So far what I can think of is saving the work in GitHub and taking it from there and VS code to work on it. Anyone has a better idea or method or suggestion? Appreciate if you can share.
DEV 7
You have been given an empty array(ARR) and its size N. The only input taken from the user will be N. Your task is to populate the array using the integer values in the range 1 to N(both inclusive) in the order - 1,3,.......4,2. Sample Input 1 : 6 Sample Output 1 : 1 3 5 6 4 2 Sample Input 2 : 9 Sample Output 2 : 1 3 5 7 9 8 6 4 2 sample output 3: 1 3 2 in c++
DEV 7
Where's your code and where did you get stuck?
#include<iostream> using namespace std; int main(){ int n; cout<<"enter array size"<<endl; cin>>n; int arr[n]; int val=1; for(int i=0;i<n/2;i++){ arr[i]=val; val=val+2; } int val2=n; for(int i=n/2;i<n;i++){ arr[i]=val2; val2=val2-2;} for(int i=0;i<n;i++){ cout<<arr[i]; } return 0; }
DEV 7
this code works for 6 but not for 5
DEV 7
and 3
Suka
doesn't really work, does it?
idk just wild guess hehe
olli
idk just wild guess hehe
I see, this would do the job though for(int i = 1; i <= n; i += 2) printf("%d ", i); for(int i = n & (~0U << 1); i > 0; i -= 2) printf("%d ", i);
DEV 7
it doesnt work after using n+1/2
olli
it doesnt work after using n+1/2
additionally your start value for the second half is wrong, it should only be n, if n is even. Or in other words it should start at the highest even number.
VENUJAN
#include <stdio.h> int main(){ int n,i,j; printf("Enter the numbers of elements :"); scanf("%d",&n); char Numbers[n]; for (i=0;i<n;i++) { printf("Enter your numbers : "); scanf("%d",&Numbers[i]); } for(j=n;j>=1;j--) { printf("%d",Numbers[j]); } return 0; }
VENUJAN
from this coding suppose to get out put like "6789"
VENUJAN
but i got Enter the numbers of elements :4 Enter your numbers : 9 Enter your numbers : 8 Enter your numbers : 7 Enter your numbers : 6 0678 -------------------------------- Process exited after 12.74 seconds with return value 0 Press any key to continue . . .
VENUJAN
like this ........why ???
a Semicolon
Anyone here works with any kind of Android Libraries injection? Using hooks or anything like that?
Anonymous
Helo too
Nils
// Resolve hostname asio::ip::tcp::resolver r(ios); auto host = co_await r.async_resolve(asio::ip::tcp::resolver::query{std::string(ws_host), "443"}, asio::use_awaitable); // SSL setup auto ssl_ctx = asio::ssl::context(asio::ssl::context::sslv23); // Connect asio::ssl::stream<asio::ip::tcp::socket> sock(ios, ssl_ctx); co_await asio::async_connect(sock, host, asio::use_awaitable); Hey, any clue what's wrong here? I simply get "no matching funvtion call to asio::async_connect :-/
Anonymous
Any c programmer I need help for assignment
Suyash
Ok
Vitrag
Dumb
Any c programmer I need help for assignment
Send the problem here and we could try to solve it
Talula
Send the problem here and we could try to solve it
Don't do that you'll get banned
Dumb
Don't do that you'll get banned
But if she/he needs help to understand how to think about it would it be warnable/bannable?
Talula
But if she/he needs help to understand how to think about it would it be warnable/bannable?
Because it works like this, if someone starts working on the problem and is stuck in the middle due logical problem or because something isn't working then that is a help, help is not doing assignment. If she/he has a problem he/she should share the problem, not say "I need help with assignment".
Dumb
Mhhh, overall you are right
Egor [UTC+5:45]
Hello everybody! I need some advice. How to use PostgreSQL correctly in c++ code? What is the best practice here? ORM or direct requests? Which library should I choose? Do I need to write my own wrapper? How to handle exceptions?
Suyash
Hi
Vitrag
Hi
VENUJAN
Write a program in C to separate odd and even integers in separate arrays. Go to the editor Test Data : Input the number of elements to be stored in the array :5 Input 5 elements in the array : element - 0 : 25 element - 1 : 47 element - 2 : 42 element - 3 : 56 element - 4 : 32 Expected Output : The Even elements are : 42 56 32 The Odd elements are : 25 47 ..................................how to do it?
VENUJAN
i tried
VENUJAN
#include <stdio.h> int main(){ int n,i,total=0; printf("Enter the numbers of elements :"); scanf("%d",&n); int odd_num[n]; int even_num[n]; int numbers[n]; for (i=0;i<n;i++){ printf("Enter your sum_of_elements : "); scanf("%d",&numbers[i]); if ((numbers[i]/2 )== 0) { odd_num[i] = numbers[i]; } else { even_num[n] = numbers[i]; } } printf("odd numbers are = %d \n",odd_num[n]); printf("even numbers are = %d \n",odd_num[n]); return 0; } this is my code . whats wrong?
VENUJAN
Enter the numbers of elements :4 Enter your sum_of_elements : 7 Enter your sum_of_elements : 8 Enter your sum_of_elements : 9 Enter your sum_of_elements : 6 odd numbers are = 1629313344 even numbers are = 1629313344 -------------------------------- Process exited after 12.78 seconds with return value 0 Press any key to continue . . . worst output....................!
Anonymous
Hi
Karan Joshi
Anyone Have CPP Book?
Anonymous
Hi
hii
shriman_deepak
#include<iostream> #include<string.h> using namespace std; int main() { char pass[20], ePass[20]; int numOne, numTwo, sum; cout<<"Create a Password: "; cin>>pass; cout<<"\nEnter Two Numbers to Add: "; cin>>numOne>>numTwo; cout<<"\nEnter the Password to See the Result: "; cin>>ePass; if(!strcmp(pass, ePass)) { sum = numOne + numTwo; cout<<endl<<numOne<<" + "<<numTwo<<" = "<<sum; } else cout<<"\nSorry! You've entered a Wrong Password!"; cout<<endl; return 0; }
Dand
hello
Dand
can you help me to subscribe my friend youtube chanel? chanel about programming tutorial
Dand
yes
Makonzy
Please I need someone to help me out with a program
Φ ☭
/get cppbookguide
Anonymous
where to download traveling api free of cost
Dima
why
バレンタインがいない柴(食用不可)
Meow
Fateme
Meow
Your profile's photo is dog.
バレンタインがいない柴(食用不可)
バレンタインがいない柴(食用不可)
Anonymous
Anyone have a cyber security group?