Void
Pointer is so hard to learn
\Device\NUL
Wait what ? *confused nick young
\Device\NUL
Pointer is so hard to learn
type ptr[x] is *(ptr + x * sizeof(type))
\Device\NUL
So, Should i avoid declaring array like int A[size]; ?
ISO C++ doesn't support Variable length array
\Device\NUL
And because It's allocated on stack, It's not dynamix
Anurag
ISO C++ doesn't support Variable length array
It also doesn't support variable strings as parameter? I assume...how do i convert these to literals?
\Device\NUL
Just use std::vector and you can use it with C and C++ I/O
Anurag
Just use std::vector and you can use it with C and C++ I/O
vector is looks complicated and hard.. it has all sorts of symbols <>... Any alternative which is simple?
\Device\NUL
It also doesn't support variable strings as parameter? I assume...how do i convert these to literals?
It's also wrong tho when accessing memory using pointer, assuming the data model is LLP64 and the int size is 4 byte.
\Device\NUL
The right conversion is this https://t.me/programminginc/476407
Anurag
type ptr[x] is *(ptr + x * sizeof(type))
I tried this alredy.... The problem was with the declaration.. i thought this makes no difference
Daulet
vector is looks complicated and hard.. it has all sorts of symbols <>... Any alternative which is simple?
That not so complicated. Simple methods push_back(), size(), resize(). You can use it like array [i]. Iterate like foreach for(auto it:vec).
Anurag
The right conversion is this https://t.me/programminginc/476407
There are two types right . One pointer only points to first member.. and the other type points to the whole array.. In the second case.. i think we don't need to do sizeof??
Anurag
That not so complicated. Simple methods push_back(), size(), resize(). You can use it like array [i]. Iterate like foreach for(auto it:vec).
I'll look into it and start using... Im just trying to learn the basic.. before going to much high level...
\Device\NUL
There are two types right . One pointer only points to first member.. and the other type points to the whole array.. In the second case.. i think we don't need to do sizeof??
Yes you need to do, because accessing pointer can be casting into another types. Yet, it's done by adding specific bytes and then access the address
\Device\NUL
long long p = -1; char *ptr = &p printf(℅hhd\n", ptr[1]) This is legal
\Device\NUL
long long p = -1; char *ptr = &p printf(℅hhd\n", ptr[1]) This is legal
(Data model LLP64) in this case, p is 8 bytes. Thus it's same with char p[8] then memset it all to -1
\Device\NUL
What is LLP64?
Data model
Anurag
Data model
thanks ..... Can you suggest me a good resource for learning pointer property?
\Device\NUL
thanks ..... Can you suggest me a good resource for learning pointer property?
Forget about my last message, my memory got rusty https://t.me/programminginc/441140
Anurag
That not so complicated. Simple methods push_back(), size(), resize(). You can use it like array [i]. Iterate like foreach for(auto it:vec).
Why do i get "Bus Error" Printed At last.. program is displaying properly except this error
Anurag
type ptr[x] is *(ptr + x * sizeof(type))
Got it.... Just to be sure . soo whenever type cast a void pointer, +/- operator automatically increments as per datatype's size?
Daulet
Got it.... Just to be sure . soo whenever type cast a void pointer, +/- operator automatically increments as per datatype's size?
for (size_t i = 0; i < size; i++) {                 cout << *(ptr + i) << endl; }
Anurag
Or you can just using for range loop
Range is only in python??
Daulet
Size_t is also datatype?
Yes. Its size depent on system. 32bit system has 32bit size_t, 64 has 64bit
\Device\NUL
Size_t is also datatype?
Typedef to scalar types that guaranteed can hold what sizeof() return
Anurag
Yes. Its size depent on system. 32bit system has 32bit size_t, 64 has 64bit
What is work of size_t .... Is it only used for integer array?
\Device\NUL
You can sizeof everything
Daulet
Anonymous
Are you sure?
Hello i wanna convert my C code to Java code can I do that?
Anurag
You can sizeof everything
I can't understand.. can you make it in detail pls
\Device\NUL
Are you sure?
https://t.me/programminginc/462467
Daulet
Hello i wanna convert my C code to Java code can I do that?
It depends what code you want to convert
\Device\NUL
Anurag
int main() { typedef(size_t); return 0; } Its showing error
Anonymous
It depends what code you want to convert
The code is : #include <stdio.h> int main () { int a,b,c; a = b = c = printf("what is a = \n"); scanf("%d", &a); printf("what is b = \n"); scanf("%d", &b); printf("what is c = \n"); scanf("%d", &c); int sum = a + b + c; printf("sum is : %d ", a + b + c); return 0; }
\Device\NUL
int main() { typedef(size_t); return 0; } Its showing error
Heck, size_t is a typedef to scalar types like int, unsigned long
Anonymous
public static void main(String args[]) { int a, b, c; Buffered reader or Scanner.......
Actually i don't know Java so can you please translate all that code and send it to me please?? I am doing this because i want to share my program as an apk and we can't convert our c code to apk right? But we can convert our Java program to an apk
\Device\NUL
Anurag
Sorry, built-in types
Ohh . So user defined data type...size_t like int...
\Device\NUL
Ohh . So user defined data type...size_t like int...
Noooo, it's compiler defined exactly
\Device\NUL
You don't need to define it manually
Anurag
Noooo, it's compiler defined exactly
Got it... In the starting like typedef long long ll;....
Daulet
https://t.me/programminginc/462467
Thats not correct. Because size_t, uintptr_t can't be accesable in Real Mode. stdlib is os dependent thing.
Anonymous
Thats not correct. Because size_t, uintptr_t can't be accesable in Real Mode. stdlib is os dependent thing.
size_t is defined in cstddef and uintptr_t is defined in cstdint. Both the headers will be available on a freestanding implementation and therefore those types will be available to use.
Anonymous
type ptr[x] is *(ptr + x * sizeof(type))
This is wrong. ptr[x] is *(ptr+x)
Anurag
Thats not correct. Because size_t, uintptr_t can't be accesable in Real Mode. stdlib is os dependent thing.
Bro.. i replaced all int, with size_t ... I get bus error after last element . And the following statements are not executed.
Anonymous
I am using cxxdriod for Android.. for running code is it supported?
I have not used cxxdroid. But cxxdroid is not a freestanding implementation but a hosted implementation. It will support the standard library in its entirety.
Anonymous
Ohkay.. can you tell me vscode freestanding or not,
No. Freestanding implementations are when you are developing for a system with no operating system.
Anonymous
You can implement own header with that types. But its not same with stdint.h.
What do you mean? cstdint is a header that must be available on freestanding implementations.
Daulet
What do you mean? cstdint is a header that must be available on freestanding implementations.
I going to useless discussion. I mean stdint.h implemented first for cstdlib and defined in c99 standart. But yes you can implement freestanding stdint.h, but formally(not in practice) that header not same with stdint.h
Anonymous
I going to useless discussion. I mean stdint.h implemented first for cstdlib and defined in c99 standart. But yes you can implement freestanding stdint.h, but formally(not in practice) that header not same with stdint.h
What the fu** are you talking about? Do you even know what a freestanding implementation is? It doesn't mean your own implementation. The C and C++ standards define two implementation types - hosted and freestanding. https://en.cppreference.com/w/cpp/freestanding Freestanding implementation is what Ammar Faizi was talking about in his original post that you and someone else were arguing about. And you said size_t and uintptr_t won't be available on those implementations. And I just proved you wrong. Don't argue without understanding what someone is trying to say.
Ludovic 'Archivist'
No. Freestanding implementations are when you are developing for a system with no operating system.
Most of the time, yes, but sometimes you just want to opt out shitty C lib and C++ libs like GNU crap for example
Anonymous
Most of the time, yes, but sometimes you just want to opt out shitty C lib and C++ libs like GNU crap for example
Yeah that is true but that wasn't the reason why the standards suggested having them 😉
Ludovic 'Archivist'
(well, you are kinda forced into accepting the freestanding part of libstdc++ since no other major library supports freestanding)