how can i cast a char type array to an int type array

Answers were Sorted based on User's Feedback



how can i cast a char type array to an int type array..

Answer / moolshankershukla

int a[10];
char b[10];
a[10]=(char) b[10]; // type casting char type into int type.

Is This Answer Correct ?    4 Yes 1 No

how can i cast a char type array to an int type array..

Answer / harish

int b[10];char a[10];
for(int i=0;i<10;i++)
b[i]=(int)a[i];

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Code Interview Questions

why array index always strats wuth zero?

2 Answers  


Sir... please give some important coding questions asked by product companies..

0 Answers  


write a function to give demostrate the functionality of 3d in 1d. function prototye: change(int value,int indexX,int indexY,int indexZ, int [] 1dArray); value=what is the date; indexX=x-asix indexY=y-axis indexZ=z-axis and 1dArray=in which and where the value is stored??

0 Answers   Nagarro,


void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(“%d”, i); }

2 Answers  


how can u draw a rectangle in C

53 Answers   Accenture, CO, Codeblocks, Cognizant, HCL, Oracle, Punjab National Bank, SAP Labs, TCS, University, Wipro,






Print an integer using only putchar. Try doing it without using extra storage.

2 Answers  


main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above

2 Answers   HCL, LG,


There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong? void main() { struct student { char name[30], rollno[6]; }stud; FILE *fp = fopen(“somefile.dat”,”r”); while(!feof(fp)) { fread(&stud, sizeof(stud), 1 , fp); puts(stud.name); } }

1 Answers  


# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }

1 Answers  


main(){ char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); }

2 Answers  


#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  


main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); }

1 Answers  


Categories