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

how to return a multiple value from a function?

5 Answers   Wipro,


void main() { char a[]="12345\0"; int i=strlen(a); printf("here in 3 %d\n",++i); }

3 Answers  


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal.

6 Answers   Fusion Systems GmbH,


What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }

1 Answers  


main() { show(); } void show() { printf("I'm the greatest"); }

2 Answers  






What is wrong with the following code? int *foo() { int *s = malloc(sizeof(int)100); assert(s != NULL); return s; }

1 Answers  


void main() { static int i=5; if(--i){ main(); printf("%d ",i); } }

1 Answers  


Hi, i have a project that the teacher want a pyramid of numbers in C# or java...when we click a button...the pyramid should be generated in a listbox/or JtextArea...and the pyramid should have the folowing form: 1 232 34543 4567654 567898765 67890109876 7890123210987 890123454321098 90123456765432109 0123456789876543210 Plz help with codes...didn't find anything on the net.

0 Answers  


why array index always strats wuth zero?

2 Answers  


#include<stdio.h> main() { FILE *ptr; char i; ptr=fopen("zzz.c","r"); while((i=fgetch(ptr))!=EOF) printf("%c",i); }

1 Answers  


write a origram swaoing valu without 3rd variable

2 Answers  


source code for delete data in array for c

1 Answers   TCS,


Categories