Anonymous
Haven't googled it yet.... thing is my notes were not making much sense
Anonymous
yo, anyone experienced with win32api, sockets, ssl?
Mahmoud
Hello can someone tell me where to start I wish to learn but don't know anything about programming
Anonymous
How to check prime number ?
Anonymous
Not in c++
Kriss
Intrested
Anonymous
You can't compare a character with a string
'START38', 'LIME108' etc are not strings.
Pavel
'START38', 'LIME108' etc are not strings.
Well I mean they try to put strings there, what term should I have used? :)
Anonymous
Well I mean they try to put strings there, what term should I have used? :)
The code is valid but it has implementation defined behavior. They are called multi character literals.
mito
#include <stdio.h> void print_array(int arr[]); int main() { // Write C code here int rem; int i = 0; int n = 54646463; int even_count = 0; int temp = n; while(n) { rem = n % 10; if (rem % 2 == 0) even_count++; n /= 10; i++; } printf("even count = %d\n", even_count); int arr[even_count]; i = 0; while(temp) { // printf("temp = %d\n", temp); rem = temp % 10; //printf("rem = %d\n", rem); if (rem % 2 == 0) { arr[i] = rem; //printf("even in array[%d] = %d\n",i, arr[i]); i++; } temp /= 10; } i = 0; print_array(arr); } void print_array(int array[]) { int len = sizeof(array); printf("\nlen array = %d\n", len); } I'm getting size of the array = 8 always. shouldn't it be even_count * size of data type in here ? In this case, i'm getting even_count = 6 i'm defining int arr[even_count]; so size of array should be even_count * sizeof(int) I'm using an online compiler btw. #c
mito
I mean the length of an array.
Pavel
Is there a way to get size for dynamically allocated memory of an array? I'm thinking of just using even_count as size of array.
you can pass even_count as a second argument to your function, yes. I'm not aware of other options
Mahmoud
Thanks
İbn
Write a program using self recall that prints the sum of numbers from 1 to a number entered by the user?
Pavel
Write a program using self recall that prints the sum of numbers from 1 to a number entered by the user?
What is self recall? Recursion? Also we here not to do your task for you, show your code and your doubts (questions) so we be able to help
İbn
Can you solution please !
İbn
No
The code
Дон
Destination point -- heap memory. Source point -- stack. Is it possible to use memcpy like this? I mean, I tried it, but failed.
줄리아 우지야노바
Show your code
İbn
Destination point -- heap memory. Source point -- stack. Is it possible to use memcpy like this? I mean, I tried it, but failed.
I will try step by step to learn ...after helped of my god .then ,i arraived the Success
Дон
Show your code
Not exactly, but: char* string = new char[current_size + 1]{}; for (size_t i = 0; i < 5; ++i) { string[i] = 'i'; } char* _string = nullptr; memcpy(_string, string, current_size + 1); delete[] string; string = new char[2*(current_size + 1)]; memcpy(string, _string, current_size + 1);
줄리아 우지야노바
you are trying to copy to _string, inited with nullptr value
줄리아 우지야노바
If you want to create _string on stack, you should do like this: char _string[SIZE]; where SIZE is constexpr value
Pavel
Destination point -- heap memory. Source point -- stack. Is it possible to use memcpy like this? I mean, I tried it, but failed.
Yes, but you shouldn't try to override several objects on stack, copying to an array, or copying data with size less than sizeof of the target value is fine
줄리아 우지야노바
Overlapping memory regions can be copied using memmove
Francis
Anyone interested, Let's build a matrix program using C?
Anonymous
Hey friends
Bot
Best way to start learning how to solve DP problems ??
Bot
Any resources?
Дон
I think, I know what doing this part of code. But what advantage does that give instead of using if-else? #ifdef USE_PEXT constexpr bool HasPext = true; #else constexpr bool HasPext = false; #endif
Pavel
I think, I know what doing this part of code. But what advantage does that give instead of using if-else? #ifdef USE_PEXT constexpr bool HasPext = true; #else constexpr bool HasPext = false; #endif
In this specific case I'm not sure what is the advantage, usually ifdefs used when you want to compile part of the code only the condition is met (e.g. it's not compatible with other compilers, or referenced libraries are not available on other architectures).
ks
29 23 19 17 13 11 7 5 3 2 (May i ask how do i print the above output? using only nested for loop and cannot use function?)
ks
here is my attempted code
ks
#include <iostream> using namespace std; int main() { int n=29; for (int i = 5; i >= 1; i--) { /*n--;*/ for (int j = i; j > 0; j--) { cout << n << " "; n--; } cout << endl; } }
Umatiya
Please send me structure progra
Umatiya
Send me answer
Pavel
Yo boys . Learn english a little bit b4 write here
Rabh
#include <iostream> using namespace std; int main() { char arr[3]={1,2,3}; cout<<arr[0]<<arr[1]<<arr[0]+arr[2]; return 0; } //Why output is 004
klimi
But char can print numbers then why so
#include <iostream> int main() { char number = 65; std::cout << number << '\n'; } And the output is expected: A
Pavel
But char can print numbers then why so
I'm not sure why you get output 004 and I'm getting output 4, it maybe our terminals interpret these special characters differently, but in any case char overload of operator<< prints character, not the integer value of that character (not index in the ascii table) https://www.asciitable.com/ Note also this: https://wandbox.org/permlink/crYQvbpUBeGvz0b3
Rabh
But why 4 is given as output
Kriss
The input is a N numbers of integers (in one line with space between them)and I want to store it in a arr[N] , how I do that(what should I learn to do that)
klimi
But why 4 is given as output
because you are are adding 2 numbers, so the result is int
klimi
1+3 = 4, 4 is displayed
klimi
#include <iostream> using namespace std; int main() { char arr[3]={1,2,3}; cout<<arr[0]<<arr[1]<<arr[0]+arr[2]; return 0; }
Pavel
But why 4 is given as output
Seems like + operator promotes the result (or even operands) to int https://wandbox.org/permlink/vjBECnJmB68tSRX2
Ludovic 'Archivist'
ASCII value
Almost, UTF-8 value representing a codepoint below 128 if you want to be accurate
Kriss
in C or c++?
In c++ and I don't know the N value
klimi
In c++ and I don't know the N value
then you will need to create std::vector (or some similar structure)
Kriss
in C or c++?
Thinking of coverting it into string and using .length()
klimi
you just need the count of the numbers but not the values?
Kriss
you just need the count of the numbers but not the values?
No I need the values , so that later I can print it in reverse order
klimi
i would use a vector for this
klimi
or a stack
Kriss
i would use a vector for this
Okay, thanks, I will try to use vector
Anonymous
Hello guys I'm working on a ATM BANKING project and I have linked safaricom, Telcom and Airtel but there is some few implicit declarations during compile time. Someone to help
Noble Friend
Hello everyone, i wish to know if there's any c programming IDE for android phones that you can recommend that is free and offline. Just like Dev C++ for android
Swara
It is free nd offline