Mat
I can reply with Rust, that i like :P
Anonymous
C is still the most used language in OS dev, and that will not change that fast. Yelling about it won't change it.
Anonymous
Sometimes all the C hate and C++ hype + C yelling is just annoying. Both are programming languages with different aims and use cases. There is no reason to yell at one or the other. Programming is more than just forcing one language in every use case.
Anonymous
I also can't understand why anyone want to use C++ for web related stuff. Just a dumb decision which language to choose for solving this problem.
Gabriel
For apps
Gabriel
C++ and swift?
Mat
For an app you can use plenty of languages. It depends on what you want to do
Gabriel
For developing apps
VJ
int main() { char arr[] = "geeksforgeeks"; char *ptr = arr; while(*ptr != '\0') ++*ptr++; printf("%s %s", arr, ptr); getchar(); return 0; }
Mat
An app is what you use to do something with the computer or phone
Mat
It's not something defined
VJ
++*ptr++ how this works in above program
Mat
++*ptr++... probably it is read as ++(*ptr++) = ++((*ptr)++) but I'm not sure
Mat
What a mess, i have to read the output to understand it🤔
VJ
Output: hffltgpshfflt
Mat
So it increase every letter one time
Ariana
++*ptr++ increments i tby 2 doesnt it?
Mat
g -> h, e -> f
Mat
One ++ increases the pointer value, the other one the char the pointer is pointing to
Ariana
++*ptr++ becomes mov rax, QWORD PTR [rbp-8] lea rdx, [rax+1] mov QWORD PTR [rbp-8], rdx movzx edx, BYTE PTR [rax] add edx, 1 mov BYTE PTR [rax], dl in godbolt
Ariana
Ah
VJ
tq
Mat
Probably if first increment the letter, after that the pointer
Mat
So *ptr += 1; ptr +=1;
Mat
(++*ptr)++ where the input of the ++ to the right is ptr
VJ
thanks @Occupato for explanation
Sujith
Is any Android app for coding C#?
Anonymous
Is any Android app for coding C#?
This is a c/c++ group, not C#
Mat
Is any Android app for coding C#?
Termux. You can do a lot of things with it
VJ
#include<stdio.h> int fun(char *str1) { char *str2 = str1; while(*++str1); return (str1-str2); } int main() { char *str = "geeksforgeeks"; printf("%d", fun(str)); //getchar(); return 0; }
VJ
output is 13
VJ
anyone explain while loop in that program
Ariana
?
Ariana
oh
Ariana
++ changes str1
Ariana
while terminates iff *++str1 == '\0'
VJ
so the value of str1 is size of characters in the str2 ??
Mat
so the value of str1 is size of characters in the str2 ??
It's pointing to the end of the string. The diference between the start and the end of the string gives you its length
VJ
will /0 ,will be counted as length???
Mat
You operate with the pointers, not with what they're pointing
Mat
in return statement wat is the value of str2???
The address of the first char of the string
VJ
then how th o/p is 13??
Mat
Length("geeksforgeeks") == 13
Mat
The address pointing to the first g and the address of the last char ('\0') have a difference of 13 positions
VJ
so while loop goest until it reaches 13('\0') in str1 ,str2 points out address of fst char in str1,in return statement str1-str2 (13-address) how is possible??
Mat
Nope
Mat
It's like str1 == (address + 13)
Mat
And str2 == address
Ariana
XD YES
Mat
address == address of the first char of the string
Mat
To hate java you need to care about it
Mat
got it tq once again
Remember that when when you're dealing w/ pointers they works with sizes. Let's take int* p; You'll have p++; That will be evaluated as p = p + sizeof(int);
VJ
in case *p++??
VJ
in case *p++??
will it be same as above??
Mat
Wrong answer😂
VJ
lol
Mat
will it be same as above??
It depends on what is done first (*p)++ or *(p++)
BinaryByter
the first one increments the value that you are pointing to
BinaryByter
the second one points to the value after the current one
BinaryByter
and then returns the pointed to value
VJ
ohh
Mat
ohh
This will help you
BinaryByter
operator precedence :D