|
Thanks for the suggestion. It helped.
|
|
|
|
|
Hi,
I have created my own ownerdrawn menu, subclassed from CMenu, implementing the MeasureItem and DrawItem methods, which works flawlessly so far. However, I would like to change the visual appearance of the complete menu border, i.e. not the border of single menu items, but the whole menu border instead. Is there a good way to achieve this? Which method do I have to reimplement?
|
|
|
|
|
|
I recently have my huffman coding work by storing all of the character frequencies in an array sorted. The coding gives me the correct binary string for each character, but that is just for the characters in the array. What if I want to encode and display the binary characters coming from how they are arranged in the file itself?
Basically, my idea is that get each of these characters in the file and store them in a char string so that I can encode them from that point on. However, my program is weird because it outputs some characters but most are just blank. This is a section of the code that gets the characters from an input file and store them into a character array. counts_char is a function that gets the frequencies of each character; it also makes its instance of an input file stream.
char *stringChar;
ifstream infile( "project2input.txt" );
infile.seekg (0, ios::end);
size = infile.tellg();
stringChar = new char[size];
while(!infile.eof())
infile>>noskipws>>stringChar;
infile.close();
counts = new int[256];
count_chars( counts );
for (int k = 0; k<size; k++)
cout<<stringChar[k];
The output looks like this:
l ░↨l
♦ ^♂ É l É l 8 l 8 l 0l ╨
List of characters in the file with their frequencies:
E (0.0351617)
J (0.0351617)
- (0.0351617)
0 (0.0351617)
2 (0.0351617)
3 (0.0351617)
4 (0.0351617)
5 (0.0351617)
6 (0.0351617)
7 (0.0351617)
8 (0.0351617)
9 (0.0351617)
I (0.0703235)
M (0.0703235)
N (0.0703235)
O (0.0703235)
U (0.0703235)
W (0.0703235)
q (0.0703235)
z (0.0703235)
G (0.0703235)
1 (0.0703235)
T (0.105485)
k (0.105485)
C (0.175809)
x (0.21097)
; (0.246132)
j (0.246132)
S (0.281294)
. (0.351617)
A (0.457103)
v (0.703235)
w (0.914205)
g (0.949367)
y (1.16034)
, (1.6526)
f (1.86357)
b (1.89873)
u (1.9339)
m (2.00422)
(2.03938)
p (2.14487)
c (2.391)
d (2.63713)
l (3.41069)
h (3.44585)
s (4.99297)
i (5.16878)
r (5.30942)
a (5.37975)
o (5.66104)
n (5.9775)
t (6.8917)
e (10.9001)
(15.225)
2899 characters
Char Symbol Codes:
E = 0000000000000000000000000000000000000000000000000000001
J = 000000000000000000000000000000000000000000000000000001
- = 00000000000000000000000000000000000000000000000000001
0 = 0000000000000000000000000000000000000000000000000001
2 = 000000000000000000000000000000000000000000000000001
3 = 00000000000000000000000000000000000000000000000001
4 = 0000000000000000000000000000000000000000000000001
5 = 000000000000000000000000000000000000000000000001
6 = 00000000000000000000000000000000000000000000001
7 = 0000000000000000000000000000000000000000000001
8 = 000000000000000000000000000000000000000000001
9 = 00000000000000000000000000000000000000000001
I = 0000000000000000000000000000000000000000001
M = 000000000000000000000000000000000000000001
N = 00000000000000000000000000000000000000001
O = 0000000000000000000000000000000000000001
U = 000000000000000000000000000000000000001
W = 00000000000000000000000000000000000001
q = 0000000000000000000000000000000000001
z = 000000000000000000000000000000000001
G = 00000000000000000000000000000000001
1 = 0000000000000000000000000000000001
T = 000000000000000000000000000000001
k = 00000000000000000000000000000001
C = 0000000000000000000000000000001
x = 000000000000000000000000000001
; = 00000000000000000000000000001
j = 0000000000000000000000000001
S = 000000000000000000000000001
. = 00000000000000000000000001
A = 0000000000000000000000001
v = 000000000000000000000001
w = 00000000000000000000001
g = 0000000000000000000001
y = 000000000000000000001
, = 00000000000000000001
f = 0000000000000000001
b = 000000000000000001
u = 00000000000000001
m = 0000000000000001
= 000000000000001
p = 00000000000001
c = 0000000000001
d = 000000000001
l = 00000000001
h = 0000000001
s = 000000001
i = 00000001
r = 0000001
a = 000001
o = 00001
n = 0001
t = 001
e = 01
= 1
The portion before the list of characters is the one where the characters are supposed to be printed out as they were in the file.
Please help me with this. Thank you.
|
|
|
|
|
Francis Paran wrote: infile.seekg (0, ios::end);
When do you seek back to the beginning?
Francis Paran wrote: infile>>noskipws>>stringChar;
Is this supposed to append to stringChar ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I already got it working by having the ifstream variable initialized at the end using the ios::ate parameter on its instance. Thank you for the advice. I wouldn't have realized what I did wrong if it wasn't for your intuitive question, asking me when I seek back to the beginning.
|
|
|
|
|
Hi, i need to write a code which can convert a raw image to anyother desired format like BMP or JPEG etc.
|
|
|
|
|
Howdy.
Best you get cracking then - or find a "ken I hav the codez plz" site.
If you had the slightest inkling of what you're doing, you'd realize that about a man-year's worth of work goes into a typical jpeg encoder. With that said, your option of (1) get (image file) format specification documents (2) Write appropriate code, will not work in a timely fashion.
You'll need to find libraries that are suitable for you, in terms of (a) price and (b) compatibility with your code and other libraries.
Have fun young jedi!
|
|
|
|
|
Spot-on, Spartan! Marked as "correct answer".
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
You don't need any library
Just use Shell apis (1 line of code to convert any format into any other format)
|
|
|
|
|
The Image::Save method that belongs to the GDI+ library can convert between certain formats.
There is a library call FFmpeg[^] that can do practically whatever you can think of.
|
|
|
|
|
another option CImage class, which in turn uses Gdi+ calls. Use it's Save method.
|
|
|
|
|
|
Hello,
I am C++/VC++ developer. I have query from long time in my mind, what is difference between 16bit/32bit/64bit OS and how (why) it affets softwares(exe/dlls). And how int size is related with all this. Like in 16 bit enviroment int is of 2 byte and so on..
Regards
|
|
|
|
|
Basically, the OS bitness has to do with the address range that the OS can use.
Considering a flat address space, 16-bit OSs can use addresses from 0 to 65536 (2 to the power 16).
Similarily for 32-bit OS it will be 0 to 4294967296 (4 GB) and for 64-bit OS it will be 0 to 18446744073709551616 (whatever).
This means as the bitness increases, the OS can handle more code and data.
The processor also needs to be matched for bitness.
This means, a 32-bit processor cannot host a 64-bit OS.
But a 64-bit processor can host a 64-bit, 32-bit or 16-bit OS.
This is because the internal storage of the processor (registers) must be wide enough.
In the case of intel processors, 16-bit processors have 16-bit registers like AX, BX, CX, DX etc.
32-bit processors have 32-bit registers like EAX, EBX, ECX, EDX etc.
And 64-bit processors have 64-bit registers like RAX, RBX, RCX, RDX etc.
This is why the size of data types like int changes.
However, for 64-bit Windows, the size of int is still 32-bit.
|
|
|
|
|
|
May I know why size of int is only 4 byte in 64bit OS? Why it has not changed as it changed previously with 16 bit and 32 bit OS.
|
|
|
|
|
|
in mfc how i can read and convert data of any type to binary ???
|
|
|
|
|
Any data is already binary (you could do bitwise operations to extract individual bits). What exactly do you want to achieve?
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
As Rajesh said, your computer is a binary device and so all data is stored as binary.
Here is some code that displays an 8 bit data as binary.
You can extend the same for any other data type.
for (unsigned i = 0; i < 8; ++i)
cout << (datatype & (1 << i)) ? '1' : '0';
|
|
|
|
|
hi there i am working on a project that reads some data from a file and storing it into nodes. i actually made some operations like adding,deleting,search ect. in singly linked list with one structure type. now i am trying to use two structure types which are;
typedef struct node {
int birth_date;
int zipcode;
int phone_num;
char first_name[50];
char last_name[50];
char city[50];
char address[50];
char email_addr[50];
struct node* fn_next;
struct node* ln_next;
struct node* birdat_next;
} NODE;
typedef struct {
int count;
NODE* head;
NODE* tail;
NODE* current;
}LIST;
and this is the block which i read and store the data and finally call add_Node function;
while ( !feof(myfile) ) {
if( !(student = (NODE*) malloc(sizeof(NODE))) ) {
printf("ERROR NOT ENOUGH MEMORY!!!\n");
exit(100);
}
fscanf(myfile,"%s", &(student->first_name) );
fscanf(myfile,"%s", &(student->last_name) );
fscanf(myfile,"%s", &(student->email_addr) );
fscanf(myfile,"%d", &(student->phone_num) );
fscanf(myfile,"%s", &(student->address) );
fscanf(myfile,"%s", &(student->city) );
fscanf(myfile,"%d", &(student->zipcode) );
add_Node(&list,student);
printf("%s\n", student->first_name );
}
}
and of course add_Node function;
void add_Node(LIST** list, NODE* student) {
if( (*list)->head == NULL ) {
student->fn_next = (*list)->head;
(*list)->head = student;
(*list)->tail = student;
printf("Adding operation is succesfull\n");
(*list)->count++;
return;
}
else {
(*list)->current = (*list)->head;
while ( (*list)->current != NULL )
(*list)->current = (*list)->current->fn_next;
(*list)->current->fn_next = student;
student->fn_next = NULL;
(*list)->tail = (*list)->current;
return;
}
}
i am taking segmentation faults in add_Node and i don't know how to fix it.
|
|
|
|
|
Sure it goes wrong, as this statement
while ( (*list)->current != NULL ) (*list)->current = (*list)->current->fn_next;
is bound to result in (*list)->current being zero/null, hence the following
(*list)->current->fn_next=...
will bomb.
Some ideas:
1.
if you want to add a node at the end of the list, and your data structures have a tail member, why not use it, rather than scanning the list?
2.
try not to have special cases. When done properly, one often does not need them. And when one does, try making the alternate paths as short as possible, they tend to have common things (such as return, and count++ of which you forgot one).
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
i changed my way to implement the linked list with only NODE structure which is the way i know well. but this fault is not acceptable for me, i am angry to myself now because i want implement to list with using LIST structure. anyway, could you explain why i can't print the data with using code like this --> list->head->first_name
|
|
|
|
|
I did not tell you to drop the LIST structure; if you want new nodes added at the tail, having a tail pointer is the obvious way of doing it, as it is much faster than searching for the last node each time.
And your original code would never reach the print statement as it bombs when you use the null reference that is the resulting of spinning the while loop. So either use the tail pointer and drop the while loop, or fix the while loop.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|