Hallo allemaal,
During the conversion of my program from Pascal to C, I was more or
less able to find the C equivalent of most Pascal functions so far.
Only four gave me some real trouble. I solved them but it could be I
overlooked something.
1) In Pascal you can declare functions inside a function. AFAIK this
is not possible with C. Or am I wrong?
2) In Pascal there exists the "in" function. Example:
if (c in ['A'..'F', '0'..'9']) then { c is hexadecimal }
This can be translated like:
if ( ((c >= 'A') && (c <= 'Z'))
|| ((c >= '0') && (c <= '9'))) .... // c is hexadecimal
I just wonder if there is a more simpler solution.
3) In Pascal I can "add" lines:
Line1 = 'File size:' + sSize + ' bytes.';
My solution:
strcpy(Line1, "File size:");
strcat(Line1, sSize);
strcat(Line1, " bytes.);
Again, I just wonder if there is a more simpler solution.
4) In Pascal I can "add" just one character of another string:
Str1 = Str2 + Str3[5];
Unfortunately strcat(Str1, Str3[5]); doesn't work, I get an error
message. My solution:
Str4[0] = Str3[5];
Str4[1] = 0;
strcpy(Str1, Str2};
strcat(Str1, Str4};
It works but in this case I'm certainly not happy with the solution.
Is there a better way?
Many thanks for any comment!
--
___
/ __|__
/ / |_/ Groetjes, Ruud Baltissen
\ \__|_\
\___| http://Ruud.C64.org