|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
17.07.2012, 08:33 | #1 |
Регистрация: 04.07.2012
Сообщений: 4
|
2 задания на С++
Нужно выполнить 2 задания на С++. Понадобится знание англ. языка (смотрите пример ниже). Сделать нужно к четвергу
Задание №1 В результате неаккуратного обращения с указателями, целочисленное значение типа int было записано по адресу, по которому в программе располагается переменная типа float (скажем, x). Приведите фрагмент кода, который позволяет прочитать это целочисленное зна-чение с указанного адреса. (Файл Test1.zip содержит заготовку Microsoft Visual C++ 7.0 проекта, в котором используется функция BadDllFunction (экспортируется из BadDll.dll), реализующая опи-санную некорректную запись некоторого целого числа по переданному адресу переменной типа float. Добавьте Ваш код вместо закомменти-рованной строки // i = … в main.cpp. Чему равно это целое число?) Заготовка: #include "BadDll.h" #include <stdio.h> int main(int argc, char* argv[]) { float x; int i = 0; BadDllFunction(&x); printf("After call to BadDllFunction x variable value is %e.\n", x); //i = ... (здесь должно быть описание) printf("Integer value stored at x variable address is %d.\n", i); getchar(); return 0; } Задание №2 Пользуясь описанием строкового типа BSTR (см. BSTR.zip), напишите собственный вариант двух системных функций SysAllocString и SysFreeString для динамического создания и последующего уничтоже-ния строк данного типа. Функция, создающая строку, должна в каче-стве параметра принимать указатель на буфер, содержащий ANSI-строку, заканчивающуюся символом ‘\0’.Указание. Для преобразования ANSI-строки в строку UNICODE воспользуйтесь функцией mbstowcs (multi bytes string to wide characters string)(описание этой функ-ции см. в crt_mbstowcs.zip). (Для простоты будем считать, что соз-даваемая Вами функция будет работать со строками, состоящими толь-ко из латинских символов.) Файл crt_mbstowcs.zip выглядит так: Converts a sequence of multibyte characters to a corresponding sequence of wide characters. size_t mbstowcs( wchar_t *wcstr, const char *mbstr, size_t count ); Routine Required Header Compatibility mbstowcs <stdlib.h> ANSI, Win 95, Win NT For additional compatibility information, see Compatibility in the Introduction. Libraries LIBC.LIB Single thread static library, retail version LIBCMT.LIB Multithread static library, retail version MSVCRT.LIB Import library for MSVCRT.DLL, retail version Return Value If mbstowcs successfully converts the source string, it returns the number of converted multibyte characters. If the wcstr argument is NULL, the function returns the required size of the destination string. If mbstowcs encounters an invalid multibyte character, it returns –1. If the return value is count, the wide-character string is not null-terminated. Parameters wcstr The address of a sequence of wide characters mbstr The address of a sequence of multibyte characters count The number of multibyte characters to convert Remarks The mbstowcs function converts count or fewer multibyte characters pointed to by mbstr to a string of corresponding wide characters that are determined by the current locale. It stores the resulting wide-character string at the address represented by wcstr. The result is similiar to a series of calls to mbtowc. If mbstowcs encounters the single-byte null character ('\0') either before or when count occurs, it converts the null character to a wide-character null character (L'\0') and stops. Thus the wide-character string at wcstr is null-terminated only if a null character is encountered during conversion. If the sequences pointed to by wcstr and mbstr overlap, the behavior is undefined. If the wcstr argument is NULL, mbstowcs returns the required size of the destination string. Example /* MBSTOWCS.CPP illustrates the behavior of the mbstowcs function */ #include <stdlib.h> #include <stdio.h> void main( void ) { int i; char *pmbnull = NULL; char *pmbhello = (char *)malloc( MB_CUR_MAX ); wchar_t *pwchello = L"Hi"; wchar_t *pwc = (wchar_t *)malloc( sizeof( wchar_t )); printf( "Convert to multibyte string:\n" ); i = wcstombs( pmbhello, pwchello, MB_CUR_MAX ); printf( "\tCharacters converted: %u\n", i ); printf( "\tHex value of first" ); printf( " multibyte character: %#.4x\n\n", pmbhello ); printf( "Convert back to wide-character string:\n" ); i = mbstowcs( pwc, pmbhello, MB_CUR_MAX ); printf( "\tCharacters converted: %u\n", i ); printf( "\tHex value of first" ); printf( " wide character: %#.4x\n\n", pwc ); } Output Convert to multibyte string: Characters converted: 1 Hex value of first multibyte character: 0x0e1a Convert back to wide-character string: Characters converted: 1 Hex value of first wide character: 0x0e1e Файл BSTR.zip выполнен в том же ключе... Кто-нибудь возьмется??? По параметрам договоримся |
17.07.2012, 09:20 | #2 |
Пользователь
Регистрация: 04.07.2012
Сообщений: 32
|
i=*(int*)&x;
|
17.07.2012, 09:29 | #3 |
Пользователь
Регистрация: 30.04.2012
Сообщений: 31
|
Бюджет какой?
|
17.07.2012, 09:32 | #4 |
Регистрация: 04.07.2012
Сообщений: 4
|
Предлагайте свою цену
|
17.07.2012, 15:27 | #5 |
Форумчанин
Регистрация: 22.05.2012
Сообщений: 352
|
Если актуально, стучитесь:
Icq: 639544131 Полное задание (bstr.зип, например) можно выслать на: Mail: politkarta@mail.ru |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
задания с++ | pksvova | Общие вопросы C/C++ | 6 | 01.11.2011 00:52 |
4 задания по С++ | chev-91 | Фриланс | 4 | 04.05.2011 15:31 |
Задания !! | sittok | Фриланс | 12 | 15.04.2011 18:50 |
задания на C# | igor17 | C# (си шарп) | 3 | 18.11.2010 13:31 |