Pavel
yep. when i make like -> it shows unlockSlot in the list
Is it the function that you added? Or its a part of some plugin/library that you use?
Max
void UPropSelectionUMG_C::UnlockSlot2(bool Unlock_) { static UFunction* fn = UObject::FindObject<UFunction>("Function PropSelectionUMG.PropSelectionUMG_C.UnlockSlot2"); UPropSelectionUMG_C_UnlockSlot2_Params params {}; params.Unlock_ = Unlock_; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; }
Anonymous
Message from Vikas Hello Guys...I am having a problem with coding a small C++ project....can someone please help me out... please text me in private if possible
▪️fateme👷🏻‍♀️
#include<stdio.h> int* increment(int a) { int* b; *b=a; *b+=1; return b; } int main() { int num=5; int*b=increment(num); printf("%d",*b); } How can I fix this code?
Pavel
#include<stdio.h> int* increment(int a) { int* b; *b=a; *b+=1; return b; } int main() { int num=5; int*b=increment(num); printf("%d",*b); } How can I fix this code?
You're accessing a not initialized pointer here, basically writing your value into some random address in memory (which would probably make the OS crash your program). *b=a; There are multiple ways to solve it, depending on what you're trying to achieve. One way would be to allocate memory in the line above with new (for C++) or malloc (for C). And after printf, delete (C++) or free (C) pointer b; But that would be a very ugly code
Лазиз
Hello 👋🏼 Create an src/important_function.c program that receives one floating-point number x and displays the result of calculating the function on the screen (rounding to one digit after the decimal point). Add a check for the input data so the program only receives numbers. For errors, display "n/a". In this quest, in addition to <stdio.h> you can use the library <math.h> How to add a check for only receiving numbers?
Pavel
Ok. How to convert char to float?
Google "convert c-string to float"
Лазиз
Google "convert c-string to float"
Yes, there’s huge informations. But I need do it only with stdio and math library
Qadeem
👋
Anonymous
char CNames[128]; for(int n=0; n<32; n++) { if(!CNames[n*4]) { strcpy(CNames+n*4,Ccy); NumCurr++; } } Question: What does !CNames[128] mean?
Pavel
char CNames[128]; for(int n=0; n<32; n++) { if(!CNames[n*4]) { strcpy(CNames+n*4,Ccy); NumCurr++; } } Question: What does !CNames[128] mean?
With the exclamation mark? !CNames[128] would mean to take a character at position 128 and return true if the value is zero (string terminator), false if it's not zero. But 128 will be out of bounds in your case, because for an array of size 128 the last valid index is 127. So calling this code will result in undefined behavior.
Pavel
char CNames[128]; for(int n=0; n<32; n++) { if(!CNames[n*4]) { strcpy(CNames+n*4,Ccy); NumCurr++; } } Question: What does !CNames[128] mean?
If you meant this line: char CNames[128]; Then it's a declaration of an array of char with name CNames and size of 128
Anonymous
The !CNames[n*4] is in a loop
Anonymous
function main() { char CNames[128]; int NumCurr = 0; int ccyIdx(char* name) { char Ccy[4]; memcpy(Ccy,name,4); Ccy[3] = 0; for(int n=0; n<32; n++) { if(!CNames[n*4]) { strcpy(CNames+n*4,Ccy); NumCurr++; return n; } if(strstr(CNames+n*4,Ccy)) return n; } return 0; } }
Anonymous
Perhaps this should provide a better framework
Pavel
When we write *b=a That means b=&a So by assigning a to *b we are specifying it's address(actually we are initializing it)
No *b = a; and b=&a; are two different expressions first dereferences the pointer and assigns the value of a to the memory that b points to. Second takes address of a and assigns it to b.
Captain
When we write *b=a That means b=&a So by assigning a to *b we are specifying it's address(actually we are initializing it)
No, *b=a means b is storing a in address where its pointing, also you should never return refrence to local as the local gets destroyed as soon as function ends. Allocate space on heap and then return like int * b = new int
Pavel
!CNames[n*4] What does that mean?
Take value of an element at position n*4 and return true if that element is equal to zero (to '\0' character), return false otherwise.
Anonymous
I need help.
Anonymous
in executing a code, I'm not getting the proper result.
klimi
cool, there must be some problem then, you should fix it
Pavel
@K11M1
Dude, why you mentioning people all around and providing zero information to help you
Pavel
Imagine people can't read your mind
DaviChan
Don't respond. Its just bait, so just ignore.
Rain Bow
Hi can i know are RPA is subset of Ai ?
Sleeves
Hello guys
Sleeves
https://hastebin.com/ezapurazam.cpp
Sleeves
https://hastebin.com/ezapurazam.cpp
This code from K&R compiles fine but it produces no output no matter what I type in. Can anyone help me figure this out
I had created a software which writes programming code as per requirement
Anonymous
can I send media inorder to explain.
Anonymous
Dude, why you mentioning people all around and providing zero information to help you
not all around honestly, I just wanted a very simple solution.
Anonymous
Say
ot group.
Anonymous
can't send media here.
klimi
can I send media inorder to explain.
No, that's forbidden by the rules.
klimi
Anonymous
yes
checkout the ot pls.
Anonymous
Anyone please ?
what's that program for?
Sleeves
what's that program for?
It’s supposed to print the longest word from a a set of words
Sleeves
It’s an exercise from K&R like I said
Anonymous
Anyone please ?
It compiles and executes fine. Just copies the input string to longest and outputs it.
Sleeves
It doesn’t give any output on my mac. I will try on another box
Anonymous
Anonymous
what's that program for?
I need your help too
Anonymous
Did you try to run it
What does executes fine mean? I input alphabet and the output was kamesalphabet as is evident from your program
Sleeves
What does executes fine mean? I input alphabet and the output was kamesalphabet as is evident from your program
Mine outputs nothing other than kames. And I added kames there to aid debugging. It gives no output no matter what input I give it. In your case I guess it executes fine
Sleeves
I have no idea why. Can't help you much there.
Thank you you’ve done enough. If you can , what os do you use and what command was used to compile ?
Sleeves
Thank you
Sleeves
Arch Linux. gcc test.c -o test
I feel like I might be missing something very basic here. This is how I do it , please correct me if I’m wrong. I’ve tried on a mac and kali box it’s all the same result. gcc test5.c -o test5 ./test5 When it prints kames , I proceed to attempt to give it input. And then nothing happens. Am I doing anything wrong there plesee ?
Ольга
Maybe some of you have some information about struct member functions? I can't figure it out
DaviChan
in C or C++? In almost all cases you would normally just use a class? Or did I get something wrong?
Владислав🇺🇦
Good evening, C++ enjoyers. (well, depending on your time zone) I stumbled upon quite strange behavior and cannot explain it nor google anything similar. It is unclear to me why foo.func(const_lambda) in the following example would call non-const member function since it is clearly not suitable for given argument. In the main code where I try to use similar code it is not calling non-const member function but fails to even compile (the error is similar to the one generated if the argument is explicit std::function<void(const std::string&)>(const_lambda): "2 overloads have similar conversions"). I think it may be because of the way std::function is implemented but the source code is too complicated for me to understand. Can you please analyse the following snippet and help me detect the issue? https://cppinsights.io/s/63e9730e Updated link https://cppinsights.io/s/971f0067 Full error message for the commented code for msvc compiler: <source>(27): error C2666: 'Foo::func': 2 overloads have similar conversions <source>(7): note: could be 'void Foo::func(const std::function<void (std::string &)> &)' <source>(6): note: or 'void Foo::func(const std::function<void (const std::string &)> &) const' <source>(27): note: while trying to match the argument list '(const std::function<void (const std::string &)>)' <source>(27): note: note: qualification adjustment (const/volatile) may be causing the ambiguity
Pavel
DaviChan
to get member functions in C however, you need to do some trickery. What I usually do is just to create free functions with the this pointer as an explicit argument. Its not quite a member function then, but for my cases usually an okay solution. As said if you are using C++ please just use a class. Structs can have member functions also, but they way I see it: they where designed to hold data, not behavior... although functionally they are pretty much the same as classes
Ольга
Struct member functions are the same as class member functions
Well, for example, if we described it in the structure, it will look like normal outside the structure? Then, I also need to describe the body of the function outside the structure (like I just need to write a function¿)
DaviChan
Okay, I understand that. And yes, you are right. Simply write a function inside of the class
DaviChan
or if you have to split the declaration and the implementation in header and cpp file, then using typedef to define the struct as a type and then using the name resolution operator in the implementation file should also work
DaviChan
pretty much the same as you would do with classes, only that you use a typedef to define the struct as a type
DaviChan
hope im not mistaken there
Ольга
Okay I trying, Thanks
DaviChan
Im afk rn, but ill be on my machine in an hour or so. Id be happy to check as well and let you know
the best for everyone
#include <stdio.h> int main(){ int var = 5; int* p; float *k; // also with double are 8 bits for each variable; int x=1000; int *q, *c; int r; printf("the value is %p\n",&var); p=&var; printf("the value is %d\n",var); // pay attention *p=10; // It's used to change the variable of it printf("the value is %p\n",&p); // p is pointing to var variable printf("the value is %d\n",var); *p=*p+1; // printf("After adding 1 = %p",&p); r=&c; printf("the value with two pointers is %d",r); // why is it not pointing the value of r }