|
You are reading 32 characters from the file, is this correct? If so then declare your str array to hold 33 to allow for the null terminator. What is the value of endptr at the end of each loop?
|
|
|
|
|
suguimoto wrote: whats happening?
strtol() is returning LONG_MAX because of overflow.
0xFFFFFC24 is too big to fit in a signed long.
Try strtoul()
|
|
|
|
|
suguimoto wrote: mem[i] = strtol(str, &endptr, 16);
Why aren't you using strtoul() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I changed to strtoul... and get the same result =/
also increased the size from 32 to 33, still get the same thing.
very weird.
But I'm still trying
|
|
|
|
|
suguimoto wrote: I changed to strtoul... and get the same result =/
How are you confirming that strtoul() is failing?
suguimoto wrote: also increased the size from 32 to 33, still get the same thing.
Why would you expect that to make a difference, since there are no more than 10 characters per line?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
suguimoto wrote: printf("%i\n\r", mem[i]);
Since mem[i] is an unsigned int , you should be using "%u" instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks!!
It's working!
I used %x to display everything as Hex, and it's working perfectly.
Thank you guys very much!!!
code:
int main(int argc, char* argv[])
{
FILE *fp;
fp = fopen("mem.ini", "rt");
char str[32];
unsigned int mem[8192];
char * endptr;
int teste;
for(int i = 0; i<8192; i++){
fgets(str, 32, fp);
mem[i] = strtoul(str, &endptr, 16);
printf("%x\n\r", mem[i]);
}
system("PAUSE");
return 0;
}
|
|
|
|
|
suguimoto wrote: for(int i = 0; i<8192; i++){
What if there are only 5, or 8193, lines in the file? It's not wise to hard-code such numbers.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
its must be huge. because it's simulating a memory in a "rom" inside a virtual processor.
i needed a function "readmemh" from verilog, but it couldnt be translated to c++, so i did it manually. this mem is going to be read a lot of times and changed a lot of times.
I think 8192 is fixed, as it was in Verilog. So i'm just gonna leave it like that
Thanks!!
|
|
|
|
|
Hello,
how to convert an CString to char* when the project is UNICODE defined?
My try is:
<code>
CString csPath = L"C:\\FolderName";
const char* acPath = (LPSTR)(LPCTSTR)csPath;
</code>
and acPath have only the first character!
thanks
break;
|
|
|
|
|
char* is ANSI
wchar_t* is UNICODE
TCHAR* is one or the other ( depending if UNICODE is defined )
change your char* to either wchar_t* or TCHAR* and it should work fine.
I would advice you to start using TCHAR and the _t**() macros, this will really help you to eliminate these prolems in the future.
|
|
|
|
|
Hello,
thanks for reply, i try to solve it!
have nice weekend!
regards
break;
|
|
|
|
|
break; wrote: acPath have only the first character!
That's because a cast isn't magic, the compiler can't read your mind and know "oh I should convert from Unicode to MBCS here". It's just doing what you've told it to. You end up with a const char* , pointing at something that is not a char , so naturally you get the wrong result.
Use the T2CA macro (or CT2CA if your compiler supports it) to do the conversion.
|
|
|
|
|
break; wrote: const char* acPath = (LPSTR)(LPCTSTR)csPath;
What are you doing here? Neither of the casts are necessary. Since you have Unicode, use:
const wchar_t* acPath = csPath;
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
When i run my application in my system the application window is looking good.But when i run my application in another system which has monitor size less than my system,scroll bar's are added both vertically and horizontally to the application window which is not looking good . Is there any way to restict the frame size auomatically during runtime so that no slide bars are added to it based on the environment in which we run.
|
|
|
|
|
When you create the main window, are the width and height parameters hard coded? If you used the resource editor the answer is probably yes. Use the function GetSystemMetrics() to find the screen size, and resize the window with SetWindowPos()
|
|
|
|
|
In SDK plateform,
How can i import a resource(say Dialog box)from a dll project to an exe project.
the aim should be not to hav the resource inside exe project, it will be included in dll project...
-- modified at 1:20 Monday 11th December, 2006
|
|
|
|
|
Can you be a little more clear about what you intend to do.
The easiest way would be to copy the resource into both projects. If the resource really is a DialogBox, then the size is not really an issue.
If you want to have a single resource and use it in both the exe and dll projects, then create a resource only dll ( a dll which contains no code and only resources ). Both projects can then load this dll and have access to the same resources.
|
|
|
|
|
Hi,
My intend is to hav that resource only in dll. the reason is memory at run time.
now by copting the resource in both project works fine, but my intention is to hav that resource in dll project only.
sir as u suggest to create a dll with resource only that i hav tried but it is giving an error 1813, using getLastError()..i.e the image file can not be find. Again i tyed to look for that image file in msdn, but didnt get proper solution..
|
|
|
|
|
All resource loading APIs take a HINSTANCE handle to the module containing the resource.
If the resource is in a dll, you use a module instance handle to the DLL.
|
|
|
|
|
hi..all
how can i use the function GetencoderClsid(L"",&CLSID);
in VC++ 6.
Please let me know about it ,it's urgent.
Thank you.
There Is Nothing Right & Wrong
|
|
|
|
|
|
What class is this method in?
|
|
|
|
|
Dear All,
I would know that what is Release mode and Debug mode ?
bye.
|
|
|
|
|
A release build is what you release to the public. A debug build is what you use when debugging. The debug version will contain a lot of extra information, hence have a larger size.
|
|
|
|