Question:
How can I copy a variable declared as a "char *" to a variable declared as either an "int" or "char" and print it out to verify it did it properly? Any help would be greatly appreciated.
Alex
Question:
How can I copy a variable declared as a "char *" to a variable declared as either an "int" or "char" and print it out to verify it did it properly? Any help would be greatly appreciated.
Alex
Can you expand your question and give an example?
here's an attempt to answer in the meantime:
Code:char *p = "blurb"; char c; c = *p; putchar (c); --------------- char *p = "11"; int i; i = atoi(p); printf ("%d", i);
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Hammer,
Here's what I'm trying to do.
typedef struct PLANE_STRUCT {
char North_Airfields[158];
} PLANETYPE;
char *bb[5];
pPlane.North_Runway[M] = bb[4];
printf("Runway = %s\n", pPlane.North_Runway[M]);
When I compile the code I get the warning,
warning C4047: '=' : 'char ' differs in levels of indirection from 'char *'
When I run this code it aborts.
Thanks!
Hammer,
I figured out what I was doing wrong.
Thanks for your help!
pPlane.North_Runway[M] is not a string but the M-th character of the string North_Airfields.