[quote]You'd have to read the image as binary, calculate coordinates, deal with palettes, then reconstruct the image file.[/quote]

MoveToEx(startoffilex+4,startoffiley+4);
LineTo(endoffilex-4,startoffiley+4);
LineTo(endoffilex-4,endoffiley-4);
LineTo(startoffilex+4,endoffiley-4);
LineTo(startoffilex+4,startoffiley+4);

That's to draw the frame. To get the bigger picture, just make a new bitmap with 8 pixels more width and height, and bitblt into the middle.

I could probably do it in a day, but I'm too lazy to, and he already said he made it output HTML.

Note that I was talking about Windows, not Linux or any other operating system.

And he doesn't have to make it CGI accessible. He can just use it to make the pictures with frames, and use <img> tags to place the framed pictures in.

Hmm, I just noticed that I forgot to load the file into memory, and to rewind() the file after I found how big it was.

I fixed that, and now it seems to get the unique strings. All that's left is to fix some other stuff.

Still has an assertion failure, though.

(edit) Pretty much fixed everything in the compression code, except for the assertion failure. I haven't been able to find anything that causes that, and when I run my debugger on it, it happens after the return statement on main().

The other day, I got an idea for a compression program, and decided to write up a function that compresses a file into "filename.compressed".

Compression function works fine, but I get a nasty assertion failure at the return of the main() function, after the file's been compressed. Assertion failure is on line 1017 of dbgheap.c, the expression being asserted is _BLOCK_TYPE_ISVALID(pHead->nBlockUse).

Here's my code:

[code]

include <stdio.h>
include <malloc.h>
include <string.h>
include <deque>

using namespace std;
void addstrings(char *first,char second) {
int size = strlen(first)+strlen(second);
char
temp = new char[size+1];
strcpy(temp,first);
strcpy(temp+strlen(
first),second);
delete [] first;
first=temp;
}

int compress(char file,int level,int additional=NULL) {
int ret=0;
FILE thefile=fopen(file,"r");
if (thefile) {
int filesize=0;
while (fgetc(thefile)!=EOF) filesize++;
if (filesize%level) {
ret=2;
if (additional)
additional=filesize;
} else {
printf("Size of file: %d\n",filesize);
rewind(thefile);
char temp = new char[filesize];
fread(temp,filesize,1,thefile);
int temp2;
int temp3;
deque<char
> table;
char *tempstring=NULL;
bool found=false;

        for (temp2=0;temp2<filesize;temp2+=level) {

            tempstring = new char[level+1];
            for (temp3=0;temp3<level;temp3++)
                tempstring[temp3]=temp[temp2+temp3];
            tempstring[temp3]=0;
            for (temp3=0;temp3<table.size();temp3++)
                if (strcmp(table[temp3],tempstring)==0) {
                    found=true;
                    break;
                }
            if (!found) table.push_back(tempstring);
        }
        char *tempfilestring = new char[strlen(file)+1];
        strcpy(tempfilestring,file);
        addstrings(&file,".compressed");
        fclose(thefile);
        thefile = fopen(file,"wb+");
        if (thefile) {
            fprintf(thefile,"%d\n",table.size());
            for (temp2=0;temp2<table.size();temp2++) 
                fprintf(thefile,"%d%s\n",temp2,table[temp2]);
            for (temp2=0;temp2<filesize;temp2+=level) {
                tempstring = new char[level+1];
                for (temp3=0;temp3<level;temp3++)
                    tempstring[temp3]=temp[temp2+temp3];
                tempstring[temp3]=0;
                for (temp3=0;temp3<table.size();temp3++)
                    if (strcmp(tempstring,table[temp3])==0) {
                        fprintf(thefile,"%d",temp3);
                        break;
                    }
            }
            fclose(thefile);
        }
        else ret = 3;
        delete [] temp;
        for (temp2=0;temp2<table.size();temp2++)
            delete [] table[temp2];
        table.clear();
    }
} else ret = 1;
return ret;

}
int main(void) {
char *buffer = new char[256];
int compression = 0;
int result=0;
while (compression<256) buffer[compression++]=0;
printf("What file?\n"); ...

Well, do you want to change the pictures themselves to have frames, or add frames around the pictures on your web page?

In the first case, you can create a bigger bitmap, and draw a frame around it.

In the second case, I'm afraid you'll have to use some HTML to get the frames around it. If you're using PHP, I'm sure you can write a function that adds a frame around a picture.

But C++ is for applications, so unless you want to write your own Apache that adds frames on your pictures, you'll have to either change the pictures(either with Photoshop or making a program that does it for you), or use HTML with the pictures.

Maybe you could write a C++ program that outputs HTML for frames around a picture?

Well, I prefer printf() to cout. If the guy wants, he can change printf() to cout, and scanf() to cin.

But they do the same thing, so it doesn't really matter.

Let me get this straight:

You want a program that will take a picture, and output a new picture with frames?

If so, it should be fairly easy, I think. Just make a bitmap with a little space on each side of the original, and then use the Windows functions to draw on that little space. A normal frame should only take about 3 lines per space, at most.

Hmmm....

Well, instead of using DirectX 8.1, you should use DirectX 9.

Did you replace the ddraw.h in DirectDraw 4 with the one for DirectDraw 9?

I looked at my own DirectX game, and found this:

IID_IDirectDraw7

Seeing as how it's case sensitive(or at least that's how my compiler works), you should try uncapitalizing the middle of the words.

What do you mean 3 users using your program? You're only going to have 1 user to your program, unless it's internet based.

If ya' mean 3 different inputs to teh program:

[code]

include <stdio.h>
define users 3

int main(void) {
printf("Input %d heights:",users);
int loop = 0;
double temp[users];
while (loop < users) {
scanf("%f",&temp[loop]);
loop++;
}
return 0;
}
[/code]

Change #define users 3 to #define users x, where x is the number of users your want.

Or something...

You only make something const(constant) if it's , well, constant. If you're going to change anything about it, or any sorts of funky errors pop up, you're better off not const-ing it.

I personally never use const, though I did take C first, so that might have something to do with it. If it's not absolutely required that you put const there, then don't.

What are you doing in your program, though?

Anyone? I found it crashes during the while loop where PeekMessage() is, but I still haven't been able to fix it.

[quote]Does this command exist in C?[/quote]

I believe it's fflush(). I could be wrong, though.

[quote]And is this the best way to read a line of input?[/quote]

If all else fails, I do something similar to this:

[code]
while ((input = getche()) != '\n' && length <= max_length) {
buffer[length] = input;
length++;
}
[/code]

How bout' something like this:

[code]
int length(char string) {
int blah = 0;
char
pointer = string;
while (*pointer++!=NULL) blah++;
return blah;
}
[/code]

Theoretically, that should give you the length of a string. Might not work since I thought it up right now.

[quote]When I use sizeof(strString) I get an error that says "Cannot apply sizeof to managed type 'System::String'."[/quote]

I didn't know there was a system class. I r teh n00b.

Apparently, that class doesn't like you using 'sizeof()' on it, so you're just going to have to manually find it's size.

[quote]#using <mscorlib.dll>[/quote]

You are using C/C++, right? If so, I didn't know you could do that.

Awright, I don't know what 'cs' is. But here's a basic idea of what you need to do:

Get input and store in variables named 'width' and 'height'
for (temp=0;temp<width;temp++)
for (temp2=0;temp2<height;temp2++)
print out '#'

How it works is it goes across:

But since theres another for loop every time it moves across one, it goes down a column:

For example, it'll start at the first #, right? It'll loop until it reaches the last one, but for every time it goes across, it makes a column with a second for loop.

Hopefully I've explained clearly enough.

Btw, I don't know what 'cs' is, but here's some C/C++ code, if it'll help:

[code]

include <stdio.h>

int main(void) {
int temp=0,temp2=0,width=0,height=0;
printf("Input width and height:\n");
scanf("%d%d",&width,&height);
for (temp=0;temp<width;temp++)
for (temp2=0;temp2<height;temp2++)
putchar('#');
return 0;
}
[/code]

That's untested, but according to all logic and reasoning available at the time of writing, it should work.

[quote]none of the 2 overloads can convert parameter 1 from type 'std::string'[/quote]

It does strings, as in the character arrays. It doesn't do objects.

To get it to work, you have to do something like this:

[code]
char *string = "Hello. I am a string";
cout << right(string);
[/code]

If there actually is a 'right()' function in there somewhere, I believe this will work:

::right(string);

[quote]HEy,are you talking about the "windows game programming in 24 hours"?
I think that book's writer was not at all serious about windows programming somehow he became serious after playing nintendo maybe i can't remember what was it hahaha..Would you mind telling me about your ability to create window games? Like, is it possible to make 3d games after learning from that book and learning c++?[/quote]

No. You can't pick up programming skills from books, and games(especially 3D) require lots of programming skills.

Well, if you want, I could cook up a console game, and you could learn from that.

Left could be done by going:

[code]

char left(char *string) {
return string[0];
}
[/code]

Right could be done like this:
[code]
char right(char *string) {
return string[strlen(string)];
}
[/code]

I'm no VB programmer, since it's my personal opinion that VB is for idiots, so I don't know what mid() does. If it gets the middle character:

[code]
char mid(char *string) {
return string/code>>1);
}
[/code]

Does this help?

From my understanding of your post, it sounds like you want to get a 2D array of seats, add passengers, and sort em'.

A 2D array will be done something like this:

[code]
bool *array = new bool[width];
for (int temp=0;temp<width;temp++)
array[temp] = new bool[height];
[/code]

Thus, you have an array of boolean values. I'll say they're true if a person's in the seat, false otherwise.

Now then, you want to add a passenger to the array? Simple with our newfound 2D array:

array[x][y] = true;

Or if you want code you can be proud of, you could set up the 2D array to be passenger objects, and edit their name, etc.

Anyways, once you set up the 2D array of anything, accessing any member is doing this:

array[x][y];

Where x is the spot out of the width, and y is the spot out of the height.

If you want to print out their seats, just do 2 for loops, going down the height, having the 2nd scroll across the width:

[code]
for (int x=0;x<width;x++)
for (int y=0;y<height;y++)
printf("%c",array[x][y]==true ? 'x':' ';
[/code]

I don't understand what you mean by sorting the passengers.

And understand this is all off the top of my head. If there's any problems, I might actually go to my compiler and work something out.

Your first program is too big.

Something like:

[code]

include <stdio.h>

void Swap(int first,int second) {
first ^= second;
second ^= first;
*first ^= second;
}
int main(void) {
int numbers[4];
for (int temp = 0;temp<3;temp++) scanf("%d",&numbers[temp]);
for (temp=0;temp<2;temp++) {
if (numbers[temp] > numbers[temp+1] )
Swap(&numbers[temp],&numbers[temp+1]);
}
if (numbers[0] > numbers[1]) Swap(&numbers[0],&numbers[1];
return 0;
}
[/code]

You said that was your first assignment, so I'm not sure you know how to use functions and whatnot, but the program I made should work. Post back any problems.

As for your second:

[code]

include <stdio.h>

int main(void) {
int temp = -1;
while (temp < 0 || temp > 1) {
printf("Input number:\n");
scanf("%d",&temp);
}
for (temp2 = 0;temp;temp/=10) temp2+=temp%10;
printf("%d",temp2);
return 0;
}
[/code]

Now then, I thought of these from my head. I didn't compile em', but post back with any errors you might have, and I can fix em'.

Do you know the position of the char?

If so:

char_array_name[position] = new_character;

char_array_name is the name of the array.
position is an integer value specifying the offset from the address of the start of the array.
new_character is the character you want it to replace it with, like 'A'.

If you don't know it:

[code]
register char temp = array;
while (
temp++ != character && temp != 0);
temp = new_character;
[/code]

temp is a pointer to the array
array is the name of the array
character is the numberical value of the character you want to find
new_character is the character you want it to change to

It'll search the array, and replace the first instance of the character you want changed to the character you want it to be.

If you want to search the whole array:

[code]
register char temp = array;
while (
temp++!=0)
if (temp == character) temp = new_character
[/code]

If you want to output it, just go:

printf("%s",array);

where array is the name of the array.

Alternatively, you can go with 'cout', but I like printf() better, I guess since C is the first language I learned.

[code]

include "main.h"

DirectInput::Initialize(void) {
int error;
char *message;
buffer = new unsigned char[256];
//Make DirectInput8
if (SUCCEEDED(error = DirectInput8Create(hinstance,DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&dinput,NULL))) {
if (SUCCEEDED(error = dinput->CreateDevice(GUID_SysKeyboard,&keyboard,NULL))) {//Make keyboard device
if (SUCCEEDED(error = dinput->CreateDevice(GUID_SysMouse,&mouse,NULL))) {//Make mouse device
//Add more stuff here
} else {//If it breaks, here's the errors for each of the 3 'if' statements.
message = GetError(error);
MessageBox(NULL,"Couldn't create mouse device",message,0);
running = false;
}
} else {
message = GetError(error);
MessageBox(NULL,"Couldn't create keyboard device",message,0);
running = false;
}
} else {
message = GetError(error);
MessageBox(NULL,"Couldn't create DirectInput",message,0);
running = false;
}
if (FAILED(error = keyboard->SetDataFormat(&c_dfDIKeyboard))) {
message = GetError(error);
MessageBox(NULL,"Couldn't set keyboard data format",message,0);
running = false;
}
if (FAILED(error = mouse->SetDataFormat(&c_dfDIMouse))) {
message = GetError(error);
MessageBox(NULL,"Couldn't set mouse data format",message,0);
running = false;
}
if (FAILED(error = keyboard->SetCooperativeLevel(hwnd,DISCL_FOREGROUND | DISCL_NONEXCLUSIVE))) {
message = GetError(error);
MessageBox(NULL,"Couldn't set keyboard cooperative level",message,0);
running = false;
}
if (FAILED(error = mouse->SetCooperativeLevel(hwnd,DISCL_FOREGROUND | DISCL_NONEXCLUSIVE))) {
message = GetError(error);
MessageBox(NULL,"Couldn't set mouse cooperative level",message,0);
running = false;
}
mouse_event = CreateEvent(NULL, FALSE, FALSE, NULL);
if (mouse_event == NULL) {
MessageBox(NULL,"Couldn't create an event for mouse device","Ruh-roh...",0);
running = false;
}
if (FAILED(error = mouse->SetEventNotification(mouse_event))) {
MessageBox(NULL,"Couldn't associate mouse interrupt with DirectInput device","Ruh-roh...",0);
running = false;
}
keyboard->Acquire();
mouse->Acquire();
if (!running) {
MessageBox(NULL,"Couldn't get DirectInput to work. No game for you!","Exiting...",0);
PostQuitMessage(0);
}
mouse_x = 0;
mouse_y = 0;
}

DirectInput::~DirectInput(void) {
if (buffer) delete [] buffer;
mouse->Unacquire();
keyboard->Unacquire();
if (keyboard != NULL)
keyboard->Release();
if (mouse != NULL)
mouse->Release();
if (dinput != NULL)
dinput->Release();
} ...

(edit) Code was too long for forum. I'm splitting it in 1/2

I'm currently working on a Direct3D class that simplifies D3D, so I can use it to make games, applications, etc.

I started on it yesterday, got it to work so it draw triangles with a different color on each vertex, and made a function that draws 2 triangles to make a quadrilateral(or at least something with 4 vertexes).

Now, before I started on making textures for the triangles/quads, I put better error handling in. Everything seemed fine. So I went and started a few changes, so I could have textures. I changed this line:

[code]#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW |D3DFVF_DIFFUSE )[/code]

to

[code]#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ |D3DFVF_TEX1 )[/code]

I updated the structure. I ran the program to see if it still worked(which it shouldn't), and it didn't, so everything went as planned. I updated the rest of the program, and when I was done, bad things happened. I went and put debug info all around the program(in addition to the message box that popped up whenever a function failed), and tried to determine the source of the problem. A few hours later, I found that for some reason, the device was lost as soon as it was created(or at least when I tried to render triangles). Interestingly, the device wasn't lost before a particular function was called, but when it was called, at the start of the function(before any code was really executed there), it was lost.

Here's the full code ...