OUTPUT???

Feb 15, 2012 at 2:47pm
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
const char arr[]="ABCD";
fun(){
printf("SIze of arr %lu\n",sizeof((unsigned long)sizeof(arr)));
}
main(){
clrscr();
fun();
}
Feb 15, 2012 at 2:53pm
You have forgot the function return types.
void fun(){

int main(){
Last edited on Feb 15, 2012 at 2:53pm
Feb 15, 2012 at 3:10pm
You also need to call fun In main
Feb 15, 2012 at 3:33pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

const char* arr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char arr2[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

void fun(void) {
	printf("Size of arr %lu\n",(unsigned long)sizeof(arr));
	printf("Size of arr2 %lu\n",(unsigned long)sizeof(arr2));
	printf("Length of arr %lu\n",(unsigned long)strlen(arr));
}

int main(void) {
	fun();

	return 0;
}

Just wondering: Should not be the size of arr2 4 bytes, too? Because arr and arr2 are both pointers to a string. On my machine arr2 is length of string incl. null terminator...
Feb 15, 2012 at 3:41pm
shadow123 wrote:
Should not be the size of arr2 4 bytes, too? Because arr and arr2 are both pointers to a string.

arr2 is an array. Not a pointer.
Feb 15, 2012 at 6:03pm
just give me the output along with explanation
Feb 16, 2012 at 4:08pm
HELP ME Regarding this,thank you!!!
Feb 16, 2012 at 4:49pm
We're not going to do it for you. If you want the output, just fix your code and then run it so you can see it for yourself. You're almost there...
Topic archived. No new replies allowed.