[QUOTE=Protocol7;34820025]It's working for me. What values are you testing with?[/QUOTE]
awefawef
awef
awefawefawefwaef
awefawefawef
awef
When I use those values, newline delimited, awefawefawefwaef is the return value of the cout.
Even on a single line it works:
[IMG]http://puu.sh/hWKT[/IMG]
snip
How can I save a struct data in a file ?
Like:
[code]
typedef struct student {
char name[40+1];
int idade;
unsigned int n_reg; /* Number of register */
} STUDENT;[/code]
I tried 100000000... times and didn't work.
I know that I need use fwrite() and fread().
to write structure:
[code]fwrite(pointer_to_struct,sizeof(your_struct),1,file)[/code]
to read it in again:
[code]fread(pointer_to_struct,sizeof(your_struct),1,file)[/code]
if you have an array, replace pointer_to_struct with the array and replace 1 with the size of the array in both examples.
Okay...Will work this ?
[code]
typedef struct student {
char name[40+1];
int idade;
unsigned int n_reg; /* Number of register */
} STUDENT;
fwrite(&STUDENT, sizeof(STUDENT), 1, file);
while ((fread(&STUDENT, sizeof(STUDENT), 1, file) == 1)
fprintf(stdout, "Name: %s\nAge: %d\nNº reg.: %u\n", student->name, student->age, student->n_reg);[/code]
[QUOTE=Cesar Augusto;34821333]Okay...Will work this ?
[code]
typedef struct student {
char name[40+1];
int idade;
unsigned int n_reg; /* Number of register */
} STUDENT;
fwrite(&STUDENT, sizeof(STUDENT), 1, file);
while ((fread(&STUDENT, sizeof(STUDENT), 1, file) == 1)
fprintf(stdout, "Name: %s\nAge: %d\nNº reg.: %u\n", student->name, student->age, student->n_reg);[/code][/QUOTE]
You have to populate the struct first:
[code]STUDENT john;
john.name = "John Fuck";
john.idade = 400;
john.n_reg = 1234567;
fwrite(&john, sizeof(STUDENT), 1, file);
[/code]
Flub, I think it'll be easier if you just used std::cout rather than typing using std::cout. I might be wrong on this though, but I find it cleaner to just type std::cout rather than what you're doing.
[QUOTE=Cesar Augusto;34821333]Okay...Will work this ?
[code]
typedef struct student {
char name[40+1];
int idade;
unsigned int n_reg; /* Number of register */
} STUDENT;
fwrite(&STUDENT, sizeof(STUDENT), 1, file);
while ((fread(&STUDENT, sizeof(STUDENT), 1, file) == 1)
fprintf(stdout, "Name: %s\nAge: %d\nNº reg.: %u\n", student->name, student->age, student->n_reg);[/code][/QUOTE]
Just look at "while"
Damn...wrong button.... :´(
This it the code for my Save As button that iv made on my project.
private void saveAsToolMenu_Click(object sender, EventArgs e)
{
saveFD.InitialDirectory = "C:";
saveFD.Title = "save a text file";
saveFD.FileName = "";
saveFD.Filter = "Text Files|*.txt|All Files|*.*";
if (saveFD.ShowDialog() != DialogResult.Cancel)
Its works fine but i don't know what the code would be for the Save button where you don't actually choose a place to save it to it just updates the last save you made and saves it to that with out having to scroll through your files and folders. Can any one help?
Look at this part of my program
[code]
void Salvar(USUARIO *x)
{
fseek(fp, 0L, SEEK_END);
if (fwrite(&x, sizeof(x), 1, fp) != 1)
{
fprintf(stderr, "Erro ao salvar o registro");
exit(1);
}
fprintf(stdout, "Registro salvo com sucesso!");
}
void ProcessOpen()
{
if ((fp = fopen("Registros.dat", "wb")) == NULL)
{
fprintf(stderr, "Erro ao abrir o registro");
exit(1);
}
}
void Ler(USUARIO *x)
{
rewind(fp);
while (fread(&x, sizeof(USUARIO), 1, fp))
fprintf(stdout, "Nome: %s\nSexo: %s\nIdade: %d\nTelefone: %d\nSalário: %.2f\nRegistrado: %d/%d/%d\n", x->nome, x->sexo, x->idade, x->telefone, x->salario, x->registrado.dia, x->registrado.mes, x->registrado.ano);
}
[/code]
Works, but I want show each information of x person. Don't appears...
Obs.: Some parts are in portuguese (dun worry)
I got a problem.
I want to make a broadcast, that sends a String to every connected client. but when I execute the command, then I get the following error, at this point:
Error:
A disposed object can not be accessed.
Object: "System.Net.Sockets.Socket".
Code:
[code]sent += socket.Send(buffer, offset + sent, size - sent, SocketFlags.None);[/code]
The error probably only happens, when it tries to send the message to "127.0.0.1"
Whole Network code:
[url]http://pastebin.com/D01U4GTy[/url]
Execution code:
[code] private void btn_send_01_Click(object sender, EventArgs e)
{
string str = "Teststring"; //String that gets send to the client
foreach(ServerThread th in cNetListener.threads)
{
Socket sck = th.connection.Client;
th.Send(sck, Encoding.UTF8.GetBytes(str), 0, str.Length, 1000);
}
}[/code]
Also, can someone take a look at my network code, and tell me if the network shit I coded is bullshit?
In C# how could i have a texture manager hold all the images and then have the classes point to the image they need? (while using safe code)
In C+ I would do something like.
MyClassImagePointer = TextureManager.GetImage(blah);
But from what i can remember c# would create a copy of the image not a pointer to it
I've tried taking a look at my webgl project once again, and I just seem unable to find the problem... I'm sure I'm missing something really obvious but I just can't quite pinpoint it. Would anybody care to take a look at it and see if they can spot my mistake?
The textured quads doesn't show up at all while the lines works fine. I'm also very certain that the texture is right as it works in my c++ opengl engine, but just not with webgl.
Here's a link to it: [url]http://dl.dropbox.com/u/40398697/WebGLProject/WebGLProject.rar[/url]
Any help is appreciated!
[QUOTE=Richy19;34833041]In C# how could i have a texture manager hold all the images and then have the classes point to the image they need? (while using safe code)
In C+ I would do something like.
MyClassImagePointer = TextureManager.GetImage(blah);
But from what i can remember c# would create a copy of the image not a pointer to it[/QUOTE]
C# is more likely to create a reference to it than a copy. You normally don't need to explicitly use pointers and ref objects.
[QUOTE=NovembrDobby;34833227]C# is more likely to create a reference to it than a copy. You normally don't need to explicitly use pointers and ref objects.[/QUOTE]
More specifically, all class objects in C# are reference types, not value types, just like in Java. Only value types (primitives and structs) get copied.
[QUOTE=WTF Nuke;34821399]Flub, I think it'll be easier if you just used std::cout rather than typing using std::cout. I might be wrong on this though, but I find it cleaner to just type std::cout rather than what you're doing.[/QUOTE]
I mainly do it because I just want to keep a bunch of statements I'm gonna use at the beginning of every shitty program I write, so I don't have to rewrite it each time.
Basically I just erase everything in int main(){} when I want to write a new program for practice.
It's a long shot, but in the source engine, anyone know why tracelines might not be registering hitboxes unless the traceline passes through the bbox of a player?
I know for a fact this doesn't happen in dod:s for example, a player can be prone on the ground and their bounding box covers their torso at most yet the trace still impacts with the player hitboxes.
Here's an example of it in my mod:
[img]http://i.imgur.com/87kMd.jpg[/img]
You can see the bbox around the player, the hitboxes on the player and the white lines representing the traces. They don't register hitting the arm hitboxes because it was outside the bbox. If I turn around slightly and shoot at the same arm hitbox but make it clip through the edge of the bbox, it works as intended. Any ideas?
Someone could help me how to use time.h ? Please. I want put automatically the time when the user data was registered.
[QUOTE=Jimbomcb;34834101]It's a long shot, but in the source engine, anyone know why tracelines might not be registering hitboxes unless the traceline passes through the bbox of a player?
I know for a fact this doesn't happen in dod:s for example, a player can be prone on the ground and their bounding box covers their torso at most yet the trace still impacts with the player hitboxes.
Here's an example of it in my mod:
[img]http://i.imgur.com/87kMd.jpg[/img]
You can see the bbox around the player, the hitboxes on the player and the white lines representing the traces. They don't register hitting the arm hitboxes because it was outside the bbox. If I turn around slightly and shoot at the same arm hitbox but make it clip through the edge of the bbox, it works as intended. Any ideas?[/QUOTE]
It's probably because the Engine uses the Bounding Box as a fast pre-pass test. Since it never enters the bounding-box it never tests the hit boxes.
Not sure there is an easy solution unfortunately. :(
So I've hit sort of a brick wall. I know what I want to do, I know how to do it in most sane languages (C, Python, Lua, etc.), but there isn't a single way to do it in Javascript that isn't fucking horrible.
What I want to do is stop execution, then resume at the same point in code. Really, nothing more than a non-busy wait... something to indicate to the VM that it can take a break and go work on something else for a while. JS is probably the only language in the world that doesn't have such a thing, and, ironically, it's probably the only language in the world that really [i]needs[/i] it, since you're sharing resources with lots of other JS programs and browsers don't have multitasking schedulers.
The setTimeout solution for this particular problem is really filthy.
How was it that you get a point in say a 2d image using an index?
I seem to remeber it was something like:
x = i / width;
y = i % width;
[QUOTE=Richy19;34838655]How was it that you get a point in say a 2d image using an index?
I seem to remeber it was something like:
x = i / width;
y = i % width;[/QUOTE]
It's either:
x = i % w; y = i / w;
or:
y = i % h; x = i / h;
Depending on whether your image is column-major or row-major.
2 C# questions, REALLY fucking urgent.
First, how do I make it so a program opens a file in the software it's meant to be opened in (like a word document in word etc)
Second, when using openxml, how do I stop the error where an edited excel file doesn't say it's unreadable when you try to open it afterwards and all the crap related to that. Thanks.
[QUOTE=Jimbomcb;34834101]It's a long shot, but in the source engine, anyone know why tracelines might not be registering hitboxes unless the traceline passes through the bbox of a player?
I know for a fact this doesn't happen in dod:s for example, a player can be prone on the ground and their bounding box covers their torso at most yet the trace still impacts with the player hitboxes.
Here's an example of it in my mod:
[img]http://i.imgur.com/87kMd.jpg[/img]
You can see the bbox around the player, the hitboxes on the player and the white lines representing the traces. They don't register hitting the arm hitboxes because it was outside the bbox. If I turn around slightly and shoot at the same arm hitbox but make it clip through the edge of the bbox, it works as intended. Any ideas?[/QUOTE]
Sounds simply like you're not masking your trace correctly.
[QUOTE=amcfaggot;34838822]Sounds simply like you're not masking your trace correctly.[/QUOTE]
The traces are being masked perfectly fine, I managed to find some of the engine level tracing stuff (from the hl2 leak by chance) and Lord Ned was right, it doesn't bother searching for hitboxes because it was using the bbox as a faster pre-pass test. Managed to work around it anyway.
-snip nevermind, cant read atm-
I'm going to need some pathfinding but i'm not using tiles. So i'm thinking of using preset waypoints and just loop through them to find the closest to the target, and then move the NPC to the closest waypoint or something.
Could I still use A* for something like that or what?
Sorry, you need to Log In to post a reply to this thread.