Sandro
how can i have the size of array
#define SIZEOF_ARRAY(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
olli
#define SIZEOF_ARRAY(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
this is most likely not going to work in his situation since the array is passed as a parameter to his function
Igor🇺🇦
Hi guys. Is there any way to find an start index of subarray within another array using any standard functions? byte* arr1 = new byte[n] { 1, 2, 3, 4 } byte* arr2 = new byte[m] { 3, 4 } => index == 2
You can use try this https://www.boost.org/doc/libs/1_75_0/libs/algorithm/doc/html/the_boost_algorithm_library/Searching/KnuthMorrisPratt.html
Pest Control Service
Vlad
Ain't it #define ARRSIZE(x) (sizeof(x) / sizeof(*x)) ?
Vlad
welcome to windows api
It does not have anything to do with winapi
olli
Ain't it #define ARRSIZE(x) (sizeof(x) / sizeof(*x)) ?
Yes, you are right. (the other version basically adds another "divide by 1"). (It cannot be used if an array is passed as parameter to a function)
Rifat
Hi, can anyone help me with this code? When I get the output, I got an unexpected letter after joining the string. https://pastebin.ubuntu.com/p/bf5kbPcJdT/
Rifat
I have placed /0
Rifat
\0
Vlad
I have placed /0
You didn't
Rifat
You didn't
:( Can you please let me know where I have to put that?
Rifat
According to the question , I can't use library function.
Vlad
https://godbolt.org/z/4vW8vY
Vitalii
(C) I have a string entered from the keyboard. How to find numbers among all words? I created pointer ptr and devided my string every time with function strtok(). Then I tried to use functions like isdigit() for each "word" and after that use atoi() if isdigit() works. However, it converts everything into number, no matter what it is - a word or real number. What should I do?...
Anonymous
Hello guy I have some trivia questions want to try
Anonymous
Them
Anonymous
Hi
Anonymous
I new here
John
Scan F
Sandro
What on earth is this horrifying macro?
https://stackoverflow.com/questions/4415524/common-array-length-macro-for-c
Igor🇺🇦
Thanks
Or this https://en.cppreference.com/w/cpp/algorithm/find_first_of If boost is not available
hazim angah
Hello
Ammar
Hello
https://www.nohello.com/2013/01/please-dont-say-just-hello-in-chat.html
hazim angah
How to find maximum and minimum in loops ?
olli
How to find maximum and minimum in loops ?
https://en.cppreference.com/w/cpp/algorithm/minmax_element
Anonymous
How to find maximum and minimum in loops ?
Create a variable min/max , then on a loop compare the items in an array with the min/min , if the current item is greater than max , assign that to max , if it's smaller than min, vice versa
Anuj
Hii everyone 😀
Anonymous
Is anyone here who know full c language?
ברני
Is anyone here who know full c language?
Probably the admins and some more, what is the question?
Dima
No one knows C at all
ברני
No one knows C at all
We should summon the creator with oijja board 😏
Anonymous
Hello every one I need c++ practice example please if any one have share it thank u
Vishal
Hello every one I need c++ practice example please if any one have share it thank u
You can try on sites like codechef, code forces and hacker rank and there are many more
YVEF
Or this https://en.cppreference.com/w/cpp/algorithm/find_first_of If boost is not available
But do you know what is a best way if I need to iterate from end to start during the search? I assume that it can be done using reverse_iterator but I'm not sure that it will work
Anonymous
Hi
Anonymous
Guys
『ᏰᏂ』 User X
Hey
Anonymous
Can anyone help
Anonymous
With c programming plz!
『ᏰᏂ』 User X
why not get course?
『ᏰᏂ』 User X
& start off with that? alot online
Alex
With c programming plz!
I will pray for you
『ᏰᏂ』 User X
haha
Anonymous
I have a problem here can not solve it tried many times
『ᏰᏂ』 User X
paste code in chat
Prince Of Persia
Does C/C++ have function for add int (4Byte) to long long (8Byte)?
mov $22, %rax
Does C/C++ have function for add int (4Byte) to long long (8Byte)?
cast the int to long long int a = 1; long long b = 1; b += (long long) a
mov $22, %rax
mov $22, %rax
to the type you need
Prince Of Persia
you just cast the int
I know but what the exactly compiler do
mov $22, %rax
I know but what the exactly compiler do
there are specific CPU instruction for casting, so the compiler uses them The result depends on the CPU architecture
mov $22, %rax
What about x86_64
there are a lot of CVT- instruction, go and see the instruction set CVT = convert They were mostly added with the SSE extentions https://en.wikipedia.org/wiki/X86_instruction_listings#Added_with_SSE
mov $22, %rax
but also the MOVZX and MOVSX and similar for simpler kind of casting
Igor🇺🇦
But do you know what is a best way if I need to iterate from end to start during the search? I assume that it can be done using reverse_iterator but I'm not sure that it will work
What do you mean "to iterate from back start" ? Do you need to find sub sequence but in reverse? Try rend and rbegin in that case
YVEF
What do you mean "to iterate from back start" ? Do you need to find sub sequence but in reverse? Try rend and rbegin in that case
yes. I need to do something like std::find_last_of ... but I have no begin and end because it just a pointers. And I wondering does there have some wrapper for pointers to make reveres iterator without implementing custom one
Andrew
hi, anyone can help me in multithreading for posix?
Andrew
i dont get the meaning of pthread_mutex_t, do i have to use a pthread_mutex_t for each thread?
『ᏰᏂ』 User X
you're asking how to use the function @andrew1923
Igor🇺🇦
yes. I need to do something like std::find_last_of ... but I have no begin and end because it just a pointers. And I wondering does there have some wrapper for pointers to make reveres iterator without implementing custom one
That depends on your pointers and structure that your elements are stored in. If it's an array or a vector you can calculate distances between pointers of it's something else depends on this something else.
Andrew
you're asking how to use the function @andrew1923
i dont understand how the mutex variable is bounded to the thread function,
Andrew
if i created a mutex variable //mutex variable creation pthread_mutex_t var; pthread_mutex_init( &var, NULL); //thread creation pthread_t th; pthread_create(&th , NULL,function,0); how the mutex variables is connected to the thread?
Igor🇺🇦
thanks. I just use std::reverse_iterator
I don't understand how reverse iterators help you, but if it does what you want OK, I guess...
Igor🇺🇦
if i created a mutex variable //mutex variable creation pthread_mutex_t var; pthread_mutex_init( &var, NULL); //thread creation pthread_t th; pthread_create(&th , NULL,function,0); how the mutex variables is connected to the thread?
Mutex are not connected to threads. They guard resources that you want to access from threads. Each thread that wants to, for example, write to a variable takes mutex before writing. Several different threads can't take the same mutex
Andrew
and create a mutex for each thread, it doesnt matter the order, just that each thread has its own mutex
Alex
and create a mutex for each thread, it doesnt matter the order, just that each thread has its own mutex
no, one mutex for one critical section. thus, if you have one var in two threads, you need one mutex