## Closed Thread Subscribe

1. I just started a class programming in C and C++ and I was trying to write like a super basic program and I am having problems getting the equation part of the code to execute...

Code:
```# include <stdio.h>

int main(void){
float celsius, fahrenheit;
printf("Please enter a temperature in degress Fahrenheit: ");
scanf("%f", &fahrenheit);
celsius = (5f / 9f) * ( (float) fahrenheit - 32f);
printf("The temperature of %f in degrees Celsius is %f.\n", fahrenheit, celsius);
return 0;
}```
It just gives me zeros as the answer. I'm sure it is something really simple I just have basically no experience :P Thanks!
You have to add an f to the end of the 5 and 9, otherwise it'll give 0 because it does integer division.
Agree x 1 (list)

2. -snip-

Anyways, for the c# winform guys here, is there a stigma against explicitly calling click events inside your program?

3. You have to add an f to the end of the 5 and 9, otherwise it'll give 0 because it does integer division.
I removed the float and just added .0 to all the integers to make them floats and then it worked. Thanks for the help.
Agree x 2 (list)

4. So i have two Vector3 values in XNA. They are a 3D camera's position and target. How can i rotate the target vector around the position and keep it at a constant distance from the position all the time?

Edited:

Also, how do i do collision with vertices and the camera's position?

5. XNA or Pygame? I already know some xna so I guess this is a stupid question but what do you guys prefer? (didn't want to make a thread)

Also is making a simple text based game ( like the good 'ol roguelikes or DwarfFortress or something ) possible with either or should I do it in java or something?

6. I removed the float and just added .0 to all the integers to make them floats and then it worked. Thanks for the help.
That actually makes them doubles. Just saying.
Agree x 2 Informative x 1 (list)

7. -whoops-

8. So i have two Vector3 values in XNA. They are a 3D camera's position and target. How can i rotate the target vector around the position and keep it at a constant distance from the position all the time?

Edited:

Also, how do i do collision with vertices and the camera's position?
Here's a camera class I wrote for a free moving camera in XNA, and the Particle class it extends from.

http://pastebin.com/zu0XMMNP http://pastebin.com/TGeUcX5X

It uses a combination of a Vector3 for the change in rotation values, and updating a matrix based on them. You can then use that matrix's forward vector and multiply it (or not) to get your target.

It's all in the UpdateViewMatrix function.

9. XNA or Pygame? I already know some xna so I guess this is a stupid question but what do you guys prefer? (didn't want to make a thread)

Also is making a simple text based game ( like the good 'ol roguelikes or DwarfFortress or something ) possible with either or should I do it in java or something?
I second this question. Of course most will say to program roguelikes in some form of Curses with c++.

10. You can make a rougelike using literally anything you have, as long as you can output things. I suggest XNA since you know it already, but I am unfamiliar with pygame so I might be biased.

11. Snip, wow oops. Wrong thread.

12. So I've got this dylib that I want to dynamically link against another dylib. Anyone know how I can do that?

Edited:

Also, the other dylib doesn't have 'lib' in its name...

13. Snip: OpenGL and me do not agree. I am forcing OpenGL to agree with me instead of retreating to DirectX.
Funny x 1 Programming King x 1 (list)

14. How can i do collisions with a Vector3 (XNA) and many, many vertices?

Edited:

Help please?

15. So I'm learning java because I heard that it's the standard language in universities (I plan to move to C++ when i'm done) But i'd like to see some example programs made in java so I could know what i'm working towards. If anyone has anything impressive that they made in java I would love it if you showed me.

16. I'm trying to use Tesseract in VB.NET, and whenever I try to call Init, it either closes without a message, or it says this:

Code:
```  Try
Dim T As New Tesseract
Using O As New OpenFileDialog
With O
If Not .ShowDialog = DialogResult.Cancel Then
Dim B As Bitmap = New Bitmap(.FileName)
T.Init(Application.ExecutablePath, "Eng", False)
Dim L As List(Of Word) = T.DoOCR(B, Rectangle.Empty)
For Each w As Word In L
MessageBox.Show(w.Text)
Next
End If
End With
End Using
Catch Ex As Exception
MessageBox.Show(Ex.Message)
End Try```
I seriously don't know what's wrong with it.

Edited:

Okay, this shit is starting to piss me off. Is there seriously not one free fucking OCR library that isn't absolute garbage?

Getting these retarded fucking errors with Puma.NET

I'm about to punch a hole in my monitor

17. Hey guys, I've got a problem that I'm stuck on for Digital Systems Design class.

We're supposed to take

f(w, x, y, z) = (w*x')+(w'*y'*z')+(w'*x'*z)+(w'*x'*y*z')

and implement it with five two-input gates or less. I've tried minterms, maxterms and genearal alegbraic manipulation but I simply cannot get this to simplify down enough to only use 5 gates. I don't need the full solution, but if someone could give me a starting point I'd sure appreciate it.

Edited:

Nevermind, I got it.

18. Okay, this shit is starting to piss me off. Is there seriously not one free fucking OCR library that isn't absolute garbage?
From my experience, no, there isn't.

19. Potentially stupid question time.

How do you get rid of the gradient and shadow Xcode applies to tab bar images in an iOS app? I've changed the images for the bar items by selecting an imported one in the storyboard, and that just adds the effects (as expected). I'm assuming I'd have to go into AppDelegate.m and set up something like this:
Code:
```// Customize the Home bar item
UIImage *barItemHome = [[UIImage imageNamed:@"home.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UIBarItem appearance] setBackgroundImage:barItemHome forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];```
This doesn't work, though, and even if it did I have no way of selecting just the "Home" bar item to apply it to and not all of the icons. Google hasn't helped me as all of the tutorials seem to work only for older iOS versions since iOS 5 decided to fuck with the way everything is called.

20. Is there a way to force visual C++ to include macro's in a static library. For example:

lib.h:
Code:
`void doStuff();`
lib.cpp:
Code:
```#include "lib.h"
#ifdef useint
void doStuff() {int bloop;}
#else
void doStuff() {bool bloop;}
#endif```
App.cpp:
Code:
```#define useint
#include "lib.h"
int main() {doStuff()}```

I say this because I am building an engine and I would like to define these macros per-build.

Edited:

XNA or Pygame? I already know some xna so I guess this is a stupid question but what do you guys prefer? (didn't want to make a thread)

Also is making a simple text based game ( like the good 'ol roguelikes or DwarfFortress or something ) possible with either or should I do it in java or something?
IF you want to make a text based game you want to just make a console application like a C++ console application using cout and cin and such.
Disagree x 2 (list)

21. I'm sort of tired, so I must be making a really stupid mistake, but here it goes.

Code:
```unsigned char m1[]="abc";
unsigned char m2[64];
for(int i=0; i<64; i++){
m2[i]='a';
}

printf("%s\n",m1);
printf("%s\n",m2);```
Output:
Code:
```abc
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaÌÌÌÌÌÌÌÌabc```
What's going on with the second line?

22. You're missing the null terminator. ( \0 )

The second line is actually 75 characters long because of that.
Agree x 2 (list)

23. Is there a way to force visual C++ to include macro's in a static library. For example:

lib.h:
Code:
`void doStuff();`
lib.cpp:
Code:
```#include "lib.h"
#ifdef useint
void doStuff() {int bloop;}
#else
void doStuff() {bool bloop;}
#endif```
App.cpp:
Code:
```#define useint
#include "lib.h"
int main() {doStuff()}```

I say this because I am building an engine and I would like to define these macros per-build.
that's not how it works, it goes by whatever macro is defined when lib.cpp is compiled.

If you really want to do what you're trying, do something like this:

lib.hpp:

```_doStuffInt();
_doStuffBool();

static void doStuff() {
#ifdef useint
_doStuffInt();
#else
_doStuffBool();
#endif
}
```

lib.cpp:

```void _doStuffInt() {int bloop;}

void _doStuffBool() {bool bloop;}
```

(also, please don't use .h for C++ header files)
Dumb x 2 (list)

24. You're missing the null terminator. ( \0 )

The second line is actually 75 characters long because of that.
Thank goodness for Facepunch help, you can always count on someone to get a response to you quickly. Sometimes after working on a bunch of code you just need a fresh pair of eyes. You're absolutely correct, I can't believe I made such a mistake with c-style strings.

The example above is a simplified version of what I'm actually dealing with, although I did narrow down the problem to that piece of code. In reality both m1 and m2 are hashes of data that might have multiple null-terminators in them, and the loop is a transformation on one of the hashes.
Friendly x 1 (list)

25. In Java, how would one go about targeting the surface of a JFrame?

26. In Java, how would one go about targeting the surface of a JFrame?
what do you mean by targeting and what do you mean by surface? You could replace the content frame with your own component and override drawComponent if that's what youre trying to do

27. I've been working with SharpDevelop for C#, but I recently got another monitor, and although you can use vertical tabs to see more of the code/ other windows,
is there any way to bind or link the scrollbars of the different windows so that when I scroll it in one it can scroll it as a whole? If not in SharpDevelop, are there any IDE's that might?

28. -Snip-

cPannel is buggy ......

29. I have a problem where the same free space is assigned to different structures in MarsMiner's saving system.

Can you please have a look at https://github.com/Tamschi/MarsMiner...ntRangeList.cs and tell me whether the conditions are correct?

The IntRangeList is supposed to store non-overlapping number ranges (inclusive start, exclusive end).

Edit: Fixed it. One missing line.

30. Ok this is really bugging me!

Code:
```
1	ItemNumber	int(11)
2	ItemName	varchar(100)	latin1_swedish_ci
3	Price	double
4	AvailableQuantity	int(11)
5	Updated_Dt	datetime```
Code:
``` private void Form1_Load(object sender, EventArgs e)
{
//Initialize mysql connection
connection = new MySqlConnection(ConnectionString);

//Get all items in datatable
DTItems = GetAllItems();

//Fill grid with items
dataGridView1.DataSource = DTItems;

}

//Get all items from database into datatable
DataTable GetAllItems()
{
try
{
//prepare query to get all records from items table
string query = "select * from items";
//prepare adapter to run query
adapter = new MySqlDataAdapter(query, connection);
DataSet DS = new DataSet();
//get query results in dataset
adapter.Fill(DS);```
It shows the data that is on the Database fine

Code:
```                    // Set the INSERT command and parameter.
adapter.InsertCommand = new MySqlCommand(
"INSERT INTO items VALUES (@ItemNumber,@ItemName,@Price,@AvailableQuantity,NOW());",
connection);
adapter.InsertCommand.Parameters.Add("@ItemNumber", MySqlDbType.Int16, 4, "1");
adapter.InsertCommand.Parameters.Add("@ItemName", MySqlDbType.VarChar, 100, "ItemName");
adapter.InsertCommand.Parameters.Add("@Price", MySqlDbType.Decimal, 10, "Price");
adapter.InsertCommand.Parameters.Add("@AvailableQuantity", MySqlDbType.Int16, 11, "AvailableQuantity");
adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;```
I followed a website that showed how to use Datagridview and MySQL , but when I try to insert anything using their code I get this.

"Column 'ItemNumber' cannot be null"

Edited:

Ok this is really bugging me!

Code:
```                    // Set the INSERT command and parameter.
adapter.InsertCommand = new MySqlCommand(
"INSERT INTO items VALUES (@ItemNumber,@ItemName,@Price,@AvailableQuantity,NOW());",
connection);
adapter.InsertCommand.Parameters.Add("@ItemNumber", MySqlDbType.Int16, 4, "1");
adapter.InsertCommand.Parameters.Add("@ItemName", MySqlDbType.VarChar, 100, "ItemName");
adapter.InsertCommand.Parameters.Add("@Price", MySqlDbType.Decimal, 10, "Price");
adapter.InsertCommand.Parameters.Add("@AvailableQuantity", MySqlDbType.Int16, 11, "AvailableQuantity");
adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;```
I followed a website that showed how to use Datagridview and MySQL , but when I try to insert anything using their code I get this.

"Column 'ItemNumber' cannot be null"

I don't know if this adds anything but I just dragged a datagriview1 onto the form, didn't modify it in anyway.

31. Style question for you guys (Keep in mind i'm coding in c#)
How do you capitalize fields, properties, methods and parameters?
The style I've been using it to use camelCase for private fields and parameters.
Public properties and methods are PascalCase.

Also, typically when does one add a "_" before a field (or is it method?) I've seen that before as well.

32. Style question for you guys (Keep in mind i'm coding in c#)
How do you capitalize fields, properties, methods and parameters?
The style I've been using it to use camelCase for private fields and parameters.
Public properties and methods are PascalCase.

Also, typically when does one add a "_" before a field (or is it method?) I've seen that before as well.
I use ReSharperCase.

Informative x 3 Useful x 1 (list)

33. SFML question here:

I'm making a textbox for my game. Basically what I'm doing is drawing the box, and then the text on top.
However there's a bit of an issue:

As you can see, since I'm just drawing text, it just keeps going even outside.

Is there a way to perform something similar to sf::Sprite::SetSubRect() but for sf::Text (efficiently?)

34. I'm pretty sure you have to use OpenGL with SFML to clip in SFML(but I haven't used sfml much, so don't quote me on that)
-----
I'm making a GUI system. I have a base class, well, kind of expected, a "Panel". All other panel types derive from this, such as the button. Now for my problem. I'm implementing a parent/children system. I have that idea planned out but have no clue on how to pass input events. They have functions such as onKeyPress and onMouseDrag but I don't know how to check for the panels under the mouse by traversing the panel tree.
---
In gist:
How do I pass events down to the proper element when all I have is a panel tree?

35. Ok this is really bugging me!

Code:
```
1	ItemNumber	int(11)
2	ItemName	varchar(100)	latin1_swedish_ci
3	Price	double
4	AvailableQuantity	int(11)
5	Updated_Dt	datetime```
Code:
``` private void Form1_Load(object sender, EventArgs e)
{
//Initialize mysql connection
connection = new MySqlConnection(ConnectionString);

//Get all items in datatable
DTItems = GetAllItems();

//Fill grid with items
dataGridView1.DataSource = DTItems;

}

//Get all items from database into datatable
DataTable GetAllItems()
{
try
{
//prepare query to get all records from items table
string query = "select * from items";
//prepare adapter to run query
adapter = new MySqlDataAdapter(query, connection);
DataSet DS = new DataSet();
//get query results in dataset
adapter.Fill(DS);```
It shows the data that is on the Database fine

Code:
```                    // Set the INSERT command and parameter.
adapter.InsertCommand = new MySqlCommand(
"INSERT INTO items VALUES (@ItemNumber,@ItemName,@Price,@AvailableQuantity,NOW());",
connection);
adapter.InsertCommand.Parameters.Add("@ItemNumber", MySqlDbType.Int16, 4, "1");
adapter.InsertCommand.Parameters.Add("@ItemName", MySqlDbType.VarChar, 100, "ItemName");
adapter.InsertCommand.Parameters.Add("@Price", MySqlDbType.Decimal, 10, "Price");
adapter.InsertCommand.Parameters.Add("@AvailableQuantity", MySqlDbType.Int16, 11, "AvailableQuantity");
adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;```
I followed a website that showed how to use Datagridview and MySQL , but when I try to insert anything using their code I get this.

"Column 'ItemNumber' cannot be null"

Edited:

Ok this is really bugging me!

Code:
```                    // Set the INSERT command and parameter.
adapter.InsertCommand = new MySqlCommand(
"INSERT INTO items VALUES (@ItemNumber,@ItemName,@Price,@AvailableQuantity,NOW());",
connection);
adapter.InsertCommand.Parameters.Add("@ItemNumber", MySqlDbType.Int16, 4, "1");
adapter.InsertCommand.Parameters.Add("@ItemName", MySqlDbType.VarChar, 100, "ItemName");
adapter.InsertCommand.Parameters.Add("@Price", MySqlDbType.Decimal, 10, "Price");
adapter.InsertCommand.Parameters.Add("@AvailableQuantity", MySqlDbType.Int16, 11, "AvailableQuantity");
adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;```
I followed a website that showed how to use Datagridview and MySQL , but when I try to insert anything using their code I get this.

"Column 'ItemNumber' cannot be null"

I don't know if this adds anything but I just dragged a datagriview1 onto the form, didn't modify it in anyway.

oh wow that website is old. turns out all it takes now is this

Code:
```                    myMySQLCommandBuilder = new MySqlCommandBuilder(adapter);

adapter.UpdateCommand = myMySQLCommandBuilder.GetUpdateCommand();
adapter.DeleteCommand = myMySQLCommandBuilder.GetDeleteCommand();
adapter.InsertCommand = myMySQLCommandBuilder.GetInsertCommand();```

36. SFML question here:

I'm making a textbox for my game. Basically what I'm doing is drawing the box, and then the text on top.
However there's a bit of an issue:

As you can see, since I'm just drawing text, it just keeps going even outside.

Is there a way to perform something similar to sf::Sprite::SetSubRect() but for sf::Text (efficiently?)
A hacky way to do it would be to render the text into sf::RenderTexture and then render that onto you sf::RenderWindow.

37. Literally banging my head on a wall.

Stuck at event handling in c#, its my first time creating my own events in c#

defined my event using

Code:
```        public delegate void NetReceivedHandler(object sender, EventArgs e, string data);
public event NetReceivedHandler NetRec;```
and
Code:
```public void ListenOnPort()
{

...

NetRec(this, EventArgs.Empty, cData);

}```

But when I define the new eventhandler, it just won't execute the events.
Code:
```public void init()
{
cNet net = new cNet()
Thread async = new Thread(delegate() { net.StartListen( "127.0.0.1", port ); } );
async.Start();
net.NetRec += new cNet.NetReceivedHandler( net_NetRec );
}

private void net_NetRec( object sender, EventArgs e, string data )
{
Console.WriteLine( "Data: " + data );
}```
I have no idea what I'm doing.

38. I'm pretty sure you have to use OpenGL with SFML to clip in SFML(but I haven't used sfml much, so don't quote me on that)
-----
I'm making a GUI system. I have a base class, well, kind of expected, a "Panel". All other panel types derive from this, such as the button. Now for my problem. I'm implementing a parent/children system. I have that idea planned out but have no clue on how to pass input events. They have functions such as onKeyPress and onMouseDrag but I don't know how to check for the panels under the mouse by traversing the panel tree.
---
In gist:
How do I pass events down to the proper element when all I have is a panel tree?
I'm assuming a panel tree is a tree of everything in the UI, in no particular order of importance, besides what is a parent of what.

I traditionally have a panel list (doubly linked lists work great for this), where the front-most panel is always at the start of the list. This makes rendering extremely easy (just render everything on the list, in order, starting at the back) Each panel can be its own tree, but the main panels (the movable and resizeable windows) are not part of any tree.

Once you have a list, sending events is also trivial. Construct a single event object for whatever's happening (I like to separate keyboard and mouse events, though,) and just send it to every panel on the list, in order. When an event 'hits' a panel (it happens within a panel) just set a variable in it to true and continue onward. It's crucial that the event goes to every panel, so that buttons and scrollbars can be released even if the panel is blocked by something. However, when a panel sees that an event has already hit a panel, it will not let any buttons be pressed, etc.

Oh, and what's nice about this system is that when a panel is given focus, just remove it from the list and insert it at the start. Simplicity.

This is probably more than you need.

39. Need help with some basic thinking in Java, I've got a working program but I feel that the structure is wrong.

You can give the program a zip file, it will extract it and then delete all empty files and all subfolders that have empty files. So basically when it's unzipped there can be X amount of folders, and those folders can have X amount of folders (and it's likely that those folders also have subfolders, this can go on). The application needs to check each subfolder until there are no more folders, delete all empty files and if the folder is empty, delete the folder aswell.

what would be a good way to implement this? A method that checks the mainfolder, and if there are directories in that folder, send it to another method that will clean the folder and check for more subfolders? The main problem is how I can check all folders without knowing the amounts of folders and subfolders.

40. Need help with some basic thinking in Java, I've got a working program but I feel that the structure is wrong.

You can give the program a zip file, it will extract it and then delete all empty files and all subfolders that have empty files. So basically when it's unzipped there can be X amount of folders, and those folders can have X amount of folders (and it's likely that those folders also have subfolders, this can go on). The application needs to check each subfolder until there are no more folders, delete all empty files and if the folder is empty, delete the folder aswell.

what would be a good way to implement this? A method that checks the mainfolder, and if there are directories in that folder, send it to another method that will clean the folder and check for more subfolders? The main problem is how I can check all folders without knowing the amounts of folders and subfolders.
Recursion.
Agree x 1 (list)