OK say I have an integer array of 15.
and a char array of 15.
What function could I use to transfer the integer array's values to the char array?
OK say I have an integer array of 15.
and a char array of 15.
What function could I use to transfer the integer array's values to the char array?
How about the assignment operator?
Naturally, any value that falls outside the range of type char will be truncated some how. Your compiler will likely warn you of it. If you want more than that, you'll have to be specific as to how you have in mind to transform integers to characters.Code:for( x = 0; x < 15; x++ ) carray[x] = iarray[x];
Quzah.
Hope is the first step on the road to disappointment.
Thanks, Quzah
ok I have run into a problem
This portion of code reads in from a file character by character, starting with a number.
I want to send the whole number to value in struct Lexeme.
But I still need to use value for strings, as well.
I hvae attempted many things, all to no avail. I am sure the problem is extremely obvious to you all, but I have been staring at this part of code for a couple of hours now.
Can someone please tell me what I'm doing wrong?
Code:typedef struct { char type[15]; char value[15]; }Lexeme; Lexeme *pointer; int LexNumber() { char ch, temp; ch = readchar(); temp = ch;////////I know the problem is with this line and while(isdigit(ch) != 0) { ch = readchar(); strcat(temp, ch);////////////////////this line } pushback(ch); return newLexeme(NUMBER); } int readchar() { char ch; ch = fgetc(readfile); if(ch == EOF) { return newLexeme(ENDOFINPUT);///displays too soon } return ch; }
I'm assuming this is a text file? And you want it a line at a time? Sounds like a good reason to use fgets. Read the line into a buffer, then walk through the buffer doing whatever it is you need to do.
Quzah.
Hope is the first step on the road to disappointment.
actually I need to read it in one character at a time. I would love to use fgets but when lexemenumber is called, I need to store the string "number" in a struct, as well as the value of that number in that struct. Since there is more on a line than just numbers, I need to read it in one char at a time and once I hit a non-number I quit.
okay, I figured it out, a break to watch DUBYA, must have made me smarter.
Funny... I didn't see that coming.