Manish
same issue with ON_CALL as well.
Anonymous
It depends on the binding
Shvmtz
Binding ?
Anonymous
For instance let's say char a[100] = "string" char b[100]= "str2"
Anonymous
You can use ptr=a[strlen(a)] strcpy(ptr,b);
Anonymous
But now
Anonymous
Hi.. can anyone explain me the logic for this code ? "To combine two Strings without using strcat() in c "
See first calculate the lenght of str1 until \0 using while loop then using while loop str1[i]=str2[j] I++ and j++ then put \0 at last of str1 print str 1 Done
Anonymous
For instance let's say char* a= "string" char* b= "str2"
Anonymous
This is const
Anonymous
Also you can literally just
Anonymous
printf("%s%s",str1,str2);
Anonymous
Now you want to, say
Anonymous
Concatenate 2 strings
Shvmtz
See? Very easy
Yea..lil confused..
Anonymous
char *concat(char *str1, char* str2) { char *ret = malloc(1+strlen(str1)+strlen(str2)); for(unsigned long i = 0; i<strlen(str1);++i) ret[i]=str1[i]; for(i=0; i<strlen(str2);++i) ret[i+strlen(str1)] = str2[i]; ret[strlen(str1)+strlen(str2)] = 0; return ret; }
Anonymous
Oh you mean to say that strcat() follow the same procedure he described.
Anonymous
But mine was easy to understand for beginner 😔
Shvmtz
Yes 🤧
Manish
Test runs fine with a raw pointer but I am not getting why this happens
Anonymous
😐😩
Anonymous
Yea..thanks buddy 😁
😁😉 you know much more than me I am bigginer
Anonymous
Finally I got it. Nice code 👍
Just read any book on any ISA
Anonymous
This is almost a standard string concatenation algorithm
Anonymous
I merely translated it to C from the assembly equivalent
Reeta
I'm not bro 😂
Dima
one more time and you’ll get warn or ban
Reeta
Identify the gender first 🙂
Anonymous
BTW @Ritik_Tiwari you can optimize it further
Anonymous
Observe how I'm not modifying str1 and str2
Anonymous
You can make them const
Anonymous
And you can make variables to hold strlen() calls instead of calling the function every time
Anonymous
I never assume the compiler and GCC and clang both behave very differently at -O3
Anonymous
Alright
Anonymous
Hello
Anonymous
Anonymous
Hello everyone, I'm trying to do a while where I make a sequence of 1 and 0 walk inside the positions. For example, a sequence of 5 positions starting from 0 to 4 would look like this: 11010 01101 10110 01011 10101 11010 / this last one does not need to be repeated since it is equal to zero
Anonymous
a bug on windows
Anonymous
offset = 0; while (offset <= mmc){ a = 0; b = 0; int maior[mmc]; memset(maior, 0, mmc*sizeof(int)); while (a < mmc/pattern->v) { for (c=0; c < pattern2->k; c++){ maior[((pattern2->onSlots[c] + a*pattern2->v) % mmc) + mmc % offset] = 1; printf("offset %d", offset); printf("maior %d-> %d\n",b, maior[b]); b++; } a++; } for (k=0; k < mmc; k++){ if ((menor[k] == 1) && (maior[k]==1)){ //printf("ACHOU em %d, menor %d, maior %d\n",k, menor[k], maior[k]); } } offset++; }
Anonymous
however if I use mmc% offset it gives an error execution of the floating point image of the recorded core. if i use offset% mmc it does not return 1 in position 0 and so on. could someone help me?
Anonymous
https://www.geeksforgeeks.org/rotate-bits-of-an-integer/
Anonymous
I believe that I cannot use this function because there is a check in each position
Anonymous
Wht's this
Emir
Is sizeof operator compile time operator or run time operator?
MᏫᎻᎯᎷᎷᎬᎠ
Emir
It's a compile time
what if len of array uknown, how do compiler know sizeof array
Intel
Guys i need help
Intel
I have tried saving/ run my first hello program in windows os with .cc but it cant run as program pls what should u do?
MᏫᎻᎯᎷᎷᎬᎠ
what if len of array uknown, how do compiler know sizeof array
Hmm yeah Looks like sizeof performs mostly compile-time computations when it's possible I just tried it
Emir
Never thought of it till this moment
Okay thanks for that answer
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
Emir
I edited
so sometimes it calculated run time, am i wrong?
Emir
okay thanks again
MᏫᎻᎯᎷᎷᎬᎠ
Please note that C++ ISO forbids variable array length
Francisco
Yeah
I guess we're talking about sizeof applied to a variable and not a type, am I right? And btw, in which cases does it evaluate at run-time?
Francisco
if array lenght is a variable, sizeof calculated runtime
But in C++ there's not such thing as "variable length array", and that's why I'm asking
Francisco
actually i asked for C language
You actually didn't, so this is new information for me
Francisco
In C may be okay, in C++ I can't think of example for that
Intel
Need help guys
Intel
I have tried saving/ run my first hello program in windows os with .cc but it cant run as program pls what should u do?
root@x4041:~#
You need to compile it first
Emir
In C may be okay, in C++ I can't think of example for that
#include <iostream> int main(){ int n = 5; int arr[n]; arr[0] = 1; std::cout << arr[0]; } In c++ with g++ i can compile that source code, how ?
Intel
You need to compile it first
Please how to do this