Results 1 to 5 of 5
Hybrid View
-
3rd June 2020 23:04 #1Registered User
Join Date: Jun:2020
Location: Bulgaria
Posts: 3
! , ? , . ! : Write a function void print_letter_of_my_strdup(char* s, unsigned short n), which prints "my_strdup[n] = L" where L is the letter or ASCII number of the letter at position n. For making a duplicate of the string use a function char *my_strdup(char *s) and for printing use function printf. Tip: Create a string to be duplicated in main() using char *s = (char *)malloc(5 * sizeof(char)); s[0] = 'a'; s[1] = 'b'; s[2] = 'c'; s[3] = 'd'; s[4] = 'e'; s[5] = 0;
, :
#include <iostream>
using namespace std;
char *my_strdup(char *s){
_asm{
push s
call strlen
add esp,4
push eax
call malloc;
pop ecx
mov ebx, s
for:
mov dl, [ebx + ecx]
mov [eax+ecx], dl
dec ecx
cmp ecx, 0
jge for
}
return s;
}
void print_letter_of_my_strdup(char* s, unsigned short n){
}
int main()
{
cout<<"Hello World";
char *s=(char *)malloc(5 *sizeof(char));
s[0]='a';
s[1]='b';
s[2]='c';
s[3]='d';
s[4]='e';
s[5]=0;
cout<<my_strdup(s)<<endl;
return 0;
}
" which prints "my_strdup[n] = L" where L is the letter or ASCII number of the letter at position n" . , ASCII .
, !!!
-
3rd June 2020 23:55 #2
print_letter_of_my_strdup(s, 0) "my_strdup[0] = a"
print_letter_of_my_strdup(s, 1) "my_strdup[1] = b"
...
print_letter_of_my_strdup(s, 3) "my_strdup[3] = d"
...
s. n- ( ).Last edited by anrieff; 3rd June 2020 at 23:55.
, . .
"640K ught to be enough for anybody" - Bill Gates, 1981
::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel
-
4th June 2020 00:19 #3Registered User
Join Date: Jun:2020
Location: Bulgaria
Posts: 3
! . ?
-
4th June 2020 02:21 #4
C
- my_strdup.Code:char* duplicate = my_strdup(s); printf("my_strdup[%d] = %c\n", n, duplicate[n]);, . .
"640K ught to be enough for anybody" - Bill Gates, 1981
::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel
-
4th June 2020 08:26 #5Registered User
Join Date: Jun:2020
Location: Bulgaria
Posts: 3
!




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in