0
Реализуйте и протестируйте функцию void P2CStr(char *s); выполняющую преобразование строки s из Pascal-формата в формат С++.
Heeelp
7 Respuestas
0
Yes, see below a code made in Pascal (free pascal compiler). The code simply dumps the content of a String in Pascal. Change the value of s variable, and pay attention to the first line. It'll be the exact count of "printable" chars in a string.
var
        s: string;
        i: integer;
begin
        s:='Mauricio';
        for i:=0 to Length(s) do
        begin
                Write(Ord(s[i]));
                if(Ord(s[i])>32)
                then
                        WriteLn('('+s[i]+')')
                else
                        WriteLn();
        end;
end.
+ 1
You're super!!!
0
Я плохо понимаю по-русски но... Let's do in English
Theoretically there's no difference in char array treatment from Pascal and C. But Pascal strings have a particular characteristic: the zero index is the length of the string.
C strings don't bring the length, but the last char is a '\0'
0
Thank you)
0
Can you show me example of this code?
0
In Other hand, the same code in C (C++ acts like). See the first char is a real char... not the count. And the last is always a \0
#include<stdio.h>
#include<string.h>
void main() {
        char *s="Mauricio";
        int i;
        for(i=0;i<=strlen(s);i++) {
                printf("%d (%c)\n", s[i], (char)(s[i]<32?'_':s[i]));
        }
}
0
Спасибо!



