• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=Richy19;42397004]I mean would it just become: [code] void operator delete[] ( void *const p ) { delete( reinterpret_cast<char *const>(p) ); } [/code][/QUOTE] Yes. I would imagine this would silence the warning.
I want to make a simple game in plain C. What's the best C (not C++) compiler? Windows or Linux. Also, I should be able to use SDL, correct?
There's not much reason to use C over a higher level language like C# or Java ( or even a more functional language like C++ ) unless you're already incredibly efficient with it and simply don't want to learn anything new, but on Linux the GCC compiler satisfies all my C needs. You'll be capable of linking and using SDL libraries as well.
Thanks much. I'm already experienced in C++ and C# (especially the former) and really just want practice using plain C because I'm crazy like that.
Does anyone here have a good way to practice data structures i'm so confused ._.
[QUOTE=Ehmmett;42403453]I don't do c#, but I'm modifying something made in c#, so I don't quite understand this error: [code]An unhandled exception of type 'System.TypeInitializationException' occurred in project.exe Additional information: The type initializer for 'project.Main' threw an exception.[/code] There's no errors in the compiler, this just shows up when i run it. What should I do to fix this?[/QUOTE] Look at the [url=http://msdn.microsoft.com/en-us/library/system.exception.innerexception.aspx]InnerException[/url]. An TypeInitializationException is thrown when an exception is thrown in a class initializer. [QUOTE=pyschomc;42403758]Does anyone here have a good way to practice data structures i'm so confused ._.[/QUOTE] Practice as in .. implement data structures? And you're looking for common data structures? Like singly- and doubly-linked lists, binary search trees and such? Uhm, you can find [url=https://en.wikipedia.org/wiki/List_of_data_structures]a bunch of them on Wikipedia[/url]. You can also probably find books on data structures, which teach them to you including providing exercises to implement them and solutions if you get stuck.
[QUOTE=Ehmmett;42404635]I managed to find that and it says : "Unable to cast object of type 'System.Char' to type 'System.String'." I'm not sure what that means, I searched the entire project and System.Char and System.String aren't referenced??? ?[/QUOTE] You have (string) infront of a variable that is of the type char
[QUOTE=Naelstrom;42398064]There's not much reason to use C over a higher level language like C# or Java ( or even a more functional language like C++ ) unless you're already incredibly efficient with it and simply don't want to learn anything new, but on Linux the GCC compiler satisfies all my C needs. You'll be capable of linking and using SDL libraries as well.[/QUOTE] I don't know, I've always loved C for being so barebones. Things like C++ and Python are so horrendously bloated, that half the stuff is almost redundant at this point. [sp]then again i'm biased because i want to be a systems programmer[/sp]
[QUOTE=Billy2600;42397897]I want to make a simple game in plain C. What's the best C (not C++) compiler? Windows or Linux. Also, I should be able to use SDL, correct?[/QUOTE] C + SDL is a nice combo. On Windows I like to use Visual Studio as a code editor, and compile with GCC. edit: Also ignoring standard compliance is not a sin when programming for desktops. There's no need to support out-of-date compilers like MSVC; feel free to use GCC's extensions if they're helpful at all as it's the de facto C compiler.
[QUOTE=Adult;42405799]I don't know, I've always loved C for being so barebones. Things like C++ and Python are so horrendously bloated, that half the stuff is almost redundant at this point. [spoiler]then again i'm biased because i want to be a systems programmer[/spoiler] (how in the fuck do you do spoilers)[/QUOTE] [noparse][sp]something here[/sp][/noparse] -> [sp]something here[/sp]
[QUOTE=Adult;42405799]I don't know, I've always loved C for being so barebones. Things like C++ and Python are so horrendously bloated, that half the stuff is almost redundant at this point. [sp]then again i'm biased because i want to be a systems programmer[/sp][/QUOTE] Some people are more efficient in some languages than others; use what best suits you. I love OOP programming so I like using C++ more, but I wouldn't mind using C or Python.
[QUOTE=Naelstrom;42406288]Some people are more efficient in some languages than others; use what best suits you. I love OOP programming so I like using C++ more, but I wouldn't mind using C or Python.[/QUOTE] If I ever feel like using OOP stuff for C-level stuff is necessary I just bind it to lua and do the OO stuff there. (which I do, frequently, lua is so cool)
[QUOTE=Ehmmett;42412929]I went looking for that and I couldn't find anything. :([/QUOTE] Maybe there's an assignment to a string variable with a char value? (string is mapped to System.String and char to System.Char). That the class initializer fails that this happens either in the static "constructor" or a in a field declaration with initialization. The inner exception should give you the exact line if you didn't deactivate debug symbols. You can use .ToString() on the char value to get it as string afterwards. [editline]5th October 2013[/editline] The line number should be in the StackTrace property, in the first frame. It's [URL="http://stackoverflow.com/a/3329072/410020"]retrieved with methods[/URL], so you probably have to inspect private fields to get it in the debugger.
[QUOTE=Ehmmett;42415222]it doesn't and i'm poking around in it now, thanks for helping.[/QUOTE] Did you use Jetbeans to decompile Terraria? I did to at first and then it left me a few "presents" [code] (int)(index2 = )index1) for ({ int num8; int index = num8 = length - 1; } ; index >= 0; --index) [/code] And after fixing all that the game was hardly able to run. So I'd suggest looking into .NET Reflector and ILSpy. Yea they both crash when extracting certain segments but luckly when .NET Reflector crashed ILSpy was still able to decompile that segment and vice versa. However if you follow my advice make sure to dump NPC.cs using ILSpy because the .NET reflector one is biased against mobs. But all in all it's amazingly stable for a decompile. [t]http://jesusfuck.me/di/7CM9/wut.png[/t]
[QUOTE=Ehmmett;42415222]it doesn't and i'm poking around in it now, thanks for helping.[/QUOTE] If it happens in the static constructor the exception doesn't show up there normally. There are settings to halt as soon as the (inner) exception is thrown (not unhandled yet), which will show you the exact site.
After being kicked out from home past monday, I've gotten a bit more time for doing some programming (got my priorities straight, right?), and I've wondered what you guys think would be the best tool for a "job" of mine. I'm not sure if I should ask here or in WAYWO, but here goes. I'm working on a web site, or to be more precise, on the backend workings of the site. Now I've been using [url="https://github.com/cesanta/mongoose"]mongoose[/url] for the past long time, because it seemed to do the job I needed very well. But I've been wondering if it would be a better idea, for flexibility purposes, to use [url="https://kore.io/"]Kore[/url]? Any opinions on both of the above? Pros and cons and such.
[QUOTE=ZeekyHBomb;42404151]Look at the [url=http://msdn.microsoft.com/en-us/library/system.exception.innerexception.aspx]InnerException[/url]. An TypeInitializationException is thrown when an exception is thrown in a class initializer. Practice as in .. implement data structures? And you're looking for common data structures? Like singly- and doubly-linked lists, binary search trees and such? Uhm, you can find [url=https://en.wikipedia.org/wiki/List_of_data_structures]a bunch of them on Wikipedia[/url]. You can also probably find books on data structures, which teach them to you including providing exercises to implement them and solutions if you get stuck.[/QUOTE] Something like that but it's for 2-3 trees and the assignment that the teacher has given us makes no sense at all, and because of that he pushed the assignment back a bit. I'm just confused on how to start on this 2-3 tree it's similar to a bst, but the bst code he gave us is not helping at all.
[CODE] import java.util.Scanner; public class ThreeInt { public static void main( String args[]) { Scanner input = new Scanner(System.in); int userInputInt; int userInputInt2; int userInputInt3; int largest; System.out.print("Enter the first integer: "); userInputInt = input.nextInt(); System.out.print("Enter the second integer: "); userInputInt2 = input.nextInt(); System.out.print("Enter the third integer: "); userInputInt3 = input.nextInt(); int sum = userInputInt + userInputInt2 + userInputInt3; int average = (userInputInt + userInputInt2 + userInputInt3) / 3; int product = userInputInt * userInputInt2 * userInputInt3; if (userInputInt > userInputInt2) { largest = userInputInt; } if (userInputInt3 > userInputInt) { largest = userInputInt3; } System.out.printf("The largest is %d", largest); } } [/CODE] On Line 39, I'm running into this when I compile. [QUOTE]Error: The local variable largest may not have been initialized[/QUOTE] What am I doing wrong here? This is Java.
[QUOTE=garychencool;42425178][CODE] import java.util.Scanner; public class ThreeInt { public static void main( String args[]) { Scanner input = new Scanner(System.in); int userInputInt; int userInputInt2; int userInputInt3; int largest; System.out.print("Enter the first integer: "); userInputInt = input.nextInt(); System.out.print("Enter the second integer: "); userInputInt2 = input.nextInt(); System.out.print("Enter the third integer: "); userInputInt3 = input.nextInt(); int sum = userInputInt + userInputInt2 + userInputInt3; int average = (userInputInt + userInputInt2 + userInputInt3) / 3; int product = userInputInt * userInputInt2 * userInputInt3; if (userInputInt > userInputInt2) { largest = userInputInt; } if (userInputInt3 > userInputInt) { largest = userInputInt3; } System.out.printf("The largest is %d", largest); } } [/CODE] On Line 39, I'm running into this when I compile. What am I doing wrong here? This is Java.[/QUOTE] Your only assignments to largest are made inside "if" statements. Even though it one of them may always be true (the two statements may be mutually exclusive) the compiler isn't smart enough to know that. You'll need to initialize "largest" with some default value or only print inside those two if statements, with an else for "something went wrong".
[QUOTE=bord2tears;42425299]Your only assignments to largest are made inside "if" statements. Even though it one of them may always be true (the two statements may be mutually exclusive) the compiler isn't smart enough to know that. You'll need to initialize "largest" with some default value or only print inside those two if statements, with an else for "something went wrong".[/QUOTE] Ok, so I assigned the "largest" variable to 0 [CODE] int largest = 0;[/CODE] Now I get warnings about how: [CODE] int sum = userInputInt + userInputInt2 + userInputInt3; int average = (userInputInt + userInputInt2 + userInputInt3) / 3; int product = userInputInt * userInputInt2 * userInputInt3; [/CODE] those variables is never read. When I run the program anyways, it works. Yay.
It's because you are just creating them, but you are never using them.
If anyone familiar with windows cmd could help me debug this.. [CODE]del %USERPROFILE%\Desktop\TerrariaServer\filebin\serverparams.cmd wget [url]http://***/serverparams.cmd[/url] call serverparams.cmd IF name=default ( del %USERPROFILE%\Desktop\TerrariaServer\filebin\serverparams.cmd call senderror.bat ) ELSE ( randomport -default -defaut -default timeout /t 5 ) IF NOT name=default ( sysresourceoutput timeout /t 10 call sysresources IF RAM GTR 1600 call %USERPROFILE%\Desktop\TerrariaServer\createserver.bat )[/CODE] Ignore the href
[QUOTE=WTF Nuke;42425633]It's because you are just creating them, but you are never using them.[/QUOTE] Ah I see, I forgot to add the print statements for those.
[QUOTE=Duze;42426261]If anyone familiar with windows cmd could help me debug this.. [CODE]del %USERPROFILE%\Desktop\TerrariaServer\filebin\serverparams.cmd wget [url]http://***/serverparams.cmd[/url] call serverparams.cmd IF name=default ( del %USERPROFILE%\Desktop\TerrariaServer\filebin\serverparams.cmd call senderror.bat ) ELSE ( randomport -default -defaut -default timeout /t 5 ) IF NOT name=default ( sysresourceoutput timeout /t 10 call sysresources IF RAM GTR 1600 call %USERPROFILE%\Desktop\TerrariaServer\createserver.bat )[/CODE] Ignore the href[/QUOTE] Well for one, Windows doesn't have wget.
Yes, but, with some Googling [url]http://users.ugent.be/~bpuype/wget/[/url] I just toss little bits into a package, and send the package over to the server
[QUOTE=garychencool;42425178][code] if (userInputInt > userInputInt2) { largest = userInputInt; } if (userInputInt3 > userInputInt) { largest = userInputInt3; }[/code][/QUOTE] This fails if userInputInt2 is largest. If you add the right else clause that also gets rid of the not-initialized warning without initializing to an unrelated value.
Hey guys! So my buddy is trying to go out with this girl but will only let him if he can solve this [code]X=3:14:45 X=gpuarray(X) if X=vectan(reverse_mode) t(1) .rt_coupon=.045 t(X)=seekfind(arctanr(X)) Else X=circplot(gpuarray(x)) end [/code] I've tried it but not having any luck. Its supposed to output three numbers. Any ideas?
[QUOTE=pyschomc;42423090]Something like that but it's for 2-3 trees and the assignment that the teacher has given us makes no sense at all, and because of that he pushed the assignment back a bit. I'm just confused on how to start on this 2-3 tree it's similar to a bst, but the bst code he gave us is not helping at all.[/QUOTE] The Wikipedia has pages on the [url=https://en.wikipedia.org/wiki/Binary_search_tree]BST[/url] and the [url=https://en.wikipedia.org/wiki/2-3_tree]2-3 tree[/url]. There are more in-depth explanations of the 2-3 tree in the external links-section. You can find explanatory videos on Youtube if you prefer that.
So why does it say the largest is 0? [IMG]http://i.imgur.com/W1OHSyy.png[/IMG] I used if statements to find out what input value was largest. This also happens with smallest. [CODE] import java.util.Scanner; public class ThreeInt { public static void main( String args[]) { Scanner input = new Scanner(System.in); //making the variables int userInputInt; int userInputInt2; int userInputInt3; int largest = 0, smallest = 0; //asking user for input System.out.print("Enter the first integer: "); userInputInt = input.nextInt(); System.out.print("Enter the second integer: "); userInputInt2 = input.nextInt(); System.out.print("Enter the third integer: "); userInputInt3 = input.nextInt(); // setting up the sum, average and product int sum = userInputInt + userInputInt2 + userInputInt3; int average = (userInputInt + userInputInt2 + userInputInt3) / 3; int product = userInputInt * userInputInt2 * userInputInt3; //if statements to find out which number is largest if (userInputInt > userInputInt2) { largest = userInputInt; } if (userInputInt3 > userInputInt) { largest = userInputInt3; } //if statements to find out which number is smallest if (userInputInt < userInputInt2) { smallest = userInputInt; } if (userInputInt3 < userInputInt) { smallest = userInputInt3; } //printing out the results System.out.printf("The sum is %d, the average is %d, the product is %d, the largest is %d, the smallest is %d", sum, average, product, largest, smallest); } } [/CODE]
[QUOTE=Tamschi;42427357][QUOTE=garychencool;42425178][code] if (userInputInt > userInputInt2) { largest = userInputInt; } if (userInputInt3 > userInputInt) { largest = userInputInt3; }[/code][/QUOTE] This fails if userInputInt2 is largest. If you add the right else clause that also gets rid of the not-initialized warning without initializing to an unrelated value.[/QUOTE] In short, don't initialize variables that don't have a sensible default value, unless it's absolutely necessary.
Sorry, you need to Log In to post a reply to this thread.