How to return anything from a C/C++ function like a string, or, array, int, or pointer. Please read on. Usually, a function can only return a single value, using the return mechanism. If you try to return more than one value from a function, only one value will be returned that appears at the rightmost place of the return statement. However, you can return multiple values from the function using the pointer, array, or structure. Using Pointers You can use pointers to return more than one value from a function by passing pointers as function parameters and use them to set multiple values which will then have visibility in the caller function. Using Array If you want to return multiple values of the same data type from a single function, then using an array is best suited because when an array name is passed as an argument then its base address is passed to the function so whatever changes made to the array is changed in the original array. Using Structure Another way to return multiple values from a function is by using structures. Structure is a user-defined datatype in C that can hold several datatypes of the same or different types. The idea is to create a structure variable containing all required data types as its members and return that from the function. We can then retrieve the values from the structure variable inside our caller function.
Very very thank you madam your video very very usefulness 🤗🤗🤗🤗🤗😊😊😊😊😇😇 I studied B.E cyber security and gate exam your videos for very useful Jenny madam
Mam now we are a family of a half a million can you imagine all of us standing in front of you in a big ground or auditorium how would it feel like ???
Hi mam,I have not clrafied y we cannot do a=a+2 , as per my understanding if we want to access the third element in array a we can do a[2],and other way may be a=a+2; if possible could you please give an example to get this
We can't do a=a+2 because here a is an internal pointer and is constant and it always points to the first value of array. In a[2] we access the address of 2nd index using that internal pointer and then we print the value at that address
@@himanu.verma_ That is internal pointer local to the main function but in returnPointer that pointer is local to that function and we can do addition arithmetic on it.
But will returning a pointer be of any use since memory allocation to local variables of function will get deallocated after function exits , thus pointing to that location will be useless
if you write int, the function would return an integer type value (4 bytes on a 64 bit machine) and if you write int*, the function would return a pointer for int data type (8 bytes on a 64 bit machine)
@@MuddadaSameera well everything you store on the memory (ram) takes a certain amount of space (number of bits or bytes) one byte (B) = 8 bits (b). You might ask why do we even have to specify the int* or char* or something else? why can't we just use some other keyword for pointers to point at all types of data. The answer to that question is: remember I said int takes 4 B on a 64 bit machine and char takes 1 B on a 64 bit machine? suppose I made a pointer and it points at an int variable now, to dereference that pointer I need the base address and the amount of bytes to move forward from that base address to successfully fetch the value that the pointer is pointing to. for example: (0x1, 0x8, 0x10, 0x18) suppose these are the 4 bytes that collectively hold the integer (10) in its binary form. pointer would be initialized with 0x1 to fetch 10 from those memory addresses, we need to move forward by 4 bytes how does the pointer know it has to move forward by 4 bytes? by the data type (int*) int* to move 4 bytes forward and fetch the value of all those bytes char* to fetch the value from the byte that it is currently pointing at (char takes 1B in a 64 bit machine) hope that helps :D ik it's a bit complex, but you'll get it!
Maam then why you are not writing it as pointer in the function defination part ( int * p) you are writing it as (int a [ ]) why so.. please explain..?I have the screenshot to help you understand better my doubt but I cant upload it here due to non-availability of options
Hello bro... Greetings , as for ur doubt.... If int *p is used in definition then pointer would have only address and in this prmb we have used array a[ ].
Already started a new course on Java +DSA.. u can check out here: www.jennyslectures.com/courses/Mastering-Data-Structures-and-Algorithms-with-JAVA-66d7fe06b4f7fa3fb969f5c5
11:24 BROOOO MIND BLOWN 🤯
Quite tricky but you did justice to it.
Thanks from Nigeria 🇳🇬
How to return anything from a C/C++ function like a string, or, array, int, or pointer. Please read on.
Usually, a function can only return a single value, using the return mechanism. If you try to return more than one value from a function, only one value will be returned that appears at the rightmost place of the return statement. However, you can return multiple values from the function using the pointer, array, or structure.
Using Pointers
You can use pointers to return more than one value from a function by passing pointers as function parameters and use them to set multiple values which will then have visibility in the caller function.
Using Array
If you want to return multiple values of the same data type from a single function, then using an array is best suited because when an array name is passed as an argument then its base address is passed to the function so whatever changes made to the array is changed in the original array.
Using Structure
Another way to return multiple values from a function is by using structures. Structure is a user-defined datatype in C that can hold several datatypes of the same or different types. The idea is to create a structure variable containing all required data types as its members and return that from the function. We can then retrieve the values from the structure variable inside our caller function.
Superbly cleared concept!!! U just nailed it!!!! In love with ur sessions.....
This was a very important concept, thank you for covering this!
Best channel for learning c language
Love the way you teach 💐❤️❤️❤️
good evening mam. 🙏🙏
Hi
Hey baby
Very very thank you madam your video very very usefulness 🤗🤗🤗🤗🤗😊😊😊😊😇😇 I studied B.E cyber security and gate exam your videos for very useful Jenny madam
thank you so muv\ch dear mam usefull for all those unable to pay......god bless you mam ....
Beautiful Concept cleared!..
You are amazing mam❤️❤️❤️❤️
Ma'am, you are more consistent than Thugesh!😅
thank you mam ji
thank you mam.😊
Mam now we are a family of a half a million can you imagine all of us standing in front of you in a big ground or auditorium how would it feel like ???
Waah ma'am aap bhut khoobsurat ho...
If a is stored in stack memory of the returnPointer function then how it's not getting deleted when control is reaching out of this function
Maam please start structures
And unions 😀
Your my crush ma'am 😊☺️☺️☺️☺️🥰🥰🥰
So in the series of c programming 🤣🤣🤣🤣🤣same line mam gjb
😂😂😂😖
Hi mam,I have not clrafied y we cannot do a=a+2 , as per my understanding if we want to access the third element in array a we can do a[2],and other way may be a=a+2;
if possible could you please give an example to get this
We can't do a=a+2 because here a is an internal pointer and is constant and it always points to the first value of array.
In a[2] we access the address of 2nd index using that internal pointer and then we print the value at that address
@@himanu.verma_ That is internal pointer local to the main function but in returnPointer that pointer is local to that function and we can do addition arithmetic on it.
@@himanu.verma_ Yes we can print the value of a[2] in the returnPointer function and also in the main function.
Thanks mam
@10:42 since a is an array, a=a+2 statement gives error
Do series similarly for java programming Mam
VİDEO STARTS AT 2:40
But will returning a pointer be of any use since memory allocation to local variables of function will get deallocated after function exits , thus pointing to that location will be useless
Good evening mam
Mam How can i join iam10th but i love this leaning
Which book is good for c beginning??
Let us C...by yashwant kanetkar
Mam jenny.😌
ANSI C BY BALGURI SWAMI
Mam, in declaration why we should write int* returnpointer instead of int returnpointer what is the difference in output?
if you write int, the function would return an integer type value (4 bytes on a 64 bit machine)
and if you write int*, the function would return a pointer for int data type (8 bytes on a 64 bit machine)
What is the need of number of bytes?
@@MuddadaSameera well everything you store on the memory (ram) takes a certain amount of space (number of bits or bytes)
one byte (B) = 8 bits (b).
You might ask why do we even have to specify the int* or char* or something else? why can't we just use some other keyword for pointers to point at all types of data.
The answer to that question is:
remember I said int takes 4 B on a 64 bit machine and char takes 1 B on a 64 bit machine?
suppose I made a pointer and it points at an int variable
now, to dereference that pointer
I need the base address and the amount of bytes to move forward from that base address to successfully fetch the value that the pointer is pointing to.
for example:
(0x1, 0x8, 0x10, 0x18) suppose these are the 4 bytes that collectively hold the integer (10) in its binary form.
pointer would be initialized with 0x1
to fetch 10 from those memory addresses, we need to move forward by 4 bytes
how does the pointer know it has to move forward by 4 bytes? by the data type (int*)
int* to move 4 bytes forward and fetch the value of all those bytes
char* to fetch the value from the byte that it is currently pointing at (char takes 1B in a 64 bit machine)
hope that helps :D
ik it's a bit complex, but you'll get it!
@@MuddadaSameera yo man, idk if you can see my last comment, I wrote so many things in it. lemme know if you can
Good mam
Love you mam
Ma'am please start core java 🥺
Maam then why you are not writing it as pointer in the function defination part ( int * p) you are writing it as (int a [ ]) why so.. please explain..?I have the screenshot to help you understand better my doubt but I cant upload it here due to non-availability of options
Hello bro... Greetings , as for ur doubt.... If int *p is used in definition then pointer would have only address and in this prmb we have used array a[ ].
please upload c programming notes those written by you mam
we want a complete OOP playlist
Everyone is first here
Until they refresh 😂😂😂😂😂
mam plzzz use high resolution camera
Madam I need tamilnadu computer trb exam MCQ
😍
Ma'am please send notes for us
Mam which book is Good for begginer in c
❤❤❤😘
Why a is treated as a pointer here not as an array?
Because the name of the array is the internal pointer to the base address of the array.
Seventh comments heart plz🤗
Course fees please
First view
mam do java also pls .....
Already started a new course on Java +DSA.. u can check out here: www.jennyslectures.com/courses/Mastering-Data-Structures-and-Algorithms-with-JAVA-66d7fe06b4f7fa3fb969f5c5
First comment
Your voice is so cute
I love ur voice
Can also find mam ji
mam please use vs code in dark mode
Skip 0:56 to 2:33
Your voice Is so cute
Hello mam
Second view
Mam please make video on how to run programmes in laptop because I am begginer plz mam
apne unacademy ka advertisement krne ke kitne rupay liye hai???