• What do you need help with? V. 3.0
    4,884 replies, posted
Well, this is embarrassing. Got myself VS2010, made a quick HW in C++, compiled it and now I can't find out how to run it, be it from VS2010 itself or from whatever directory it's at. Never fucking mind, that's what I get for making a blank project rather than a Win32 console app.
[QUOTE=Forumaster;32186956]Hopefully you guys can help me with this C++ problem I'm having. I'm trying to create an all in one utility wrapper so to speak to back up an assload of Windows 7 computers. They want it to use WBAdmin due to the lack of having to install excess software and it creates nice VHDs. Here's my problem: (I have full administrator rights) I can run WBAdmin just fine from a command prompt and from a bat/cmd file. However, when I try to run it from my program, it will fail saying "File not found": [code] ProcessStartInfo^ backup7 = gcnew ProcessStartInfo("cmd.exe"); backup7->Arguments = "/k C:\\Windows\\System32\\wbadmin.exe"; Process::Start(backup7); [/code] I've also tried: [code] ProcessStartInfo^ backup7 = gcnew ProcessStartInfo("wbadmin.exe"); backup7->Arguments = "WB Args here"; Process::Start(backup7); [/code] Not only that, but running the batch file via this method causes it to fail: (WBLoader is in the same directory as my exe) [code] ProcessStartInfo^ backup7 = gcnew ProcessStartInfo("cmd.exe"); backup7->Arguments = "WBLoader.bat"; Process::Start(backup7); [/code] Oh, and using the Bat to EXE converter also fails. The resulting EXE also spits out a file now found error. Also I've tried putting my EXE in the System32 directory where WBAdmin is, and it STILL doesn't work. Every other external program I've tried to run this way has worked, but not this one. Does anyone have any ideas?[/QUOTE] If anyone DOES know why this isn't working, please tell me. I'd like to not have my program doing stuff in a roundabout way.
I'm not entirely sure if this would go in Windows or here, but I'll ask it here. I need a batch script that will search for certain named folders inside a named folder in all the folders in a directory. Now, as confusing as that is, let me explain what I mean. Say I have the directory: A. Inside of A, there is 1, 2, and 3. Inside of each of those, there is a folder named stuff. Inside stuff, there are x, y, and z. I want to remove x, y, and z. Now, this has to be batch because there can't be any third party programs.
Are there a way to set the value for a trackbar in c# ?
"trackbar.Value = number;" where number is a int.
[QUOTE=Fox-Face;32254288]"trackbar.Value = number;" where number is a int.[/QUOTE] Thank you sir!
Being lame and making a simple converter. Starting with temp and moving to weight. But, I have a problem. C = (F - 32) x 5/9 is how you get from F to C. Simple, right? Well, I could explain it, but I probably wouldn't make any sense, so here is the code. [code]void fToC() { convertPt1 = cel - 32; cel = convertPt1 * (5.0f/9.0f); }[/code] [b](5.0f/9.0f)[/b] Was changed from [b]5/9[/b] because of something someone else said. I tried it, and it still doesn't work. My question? How do you declare it as a fraction(5/9ths), or is there something else to do? If I'm not making any sense, I can try and rephrase everything. I'm still new(ish).
What's the problem?
[QUOTE=Werem00se;32256140]Being lame and making a simple converter. Starting with temp and moving to weight. But, I have a problem. C = (F - 32) x 5/9 is how you get from F to C. Simple, right? Well, I could explain it, but I probably wouldn't make any sense, so here is the code. [code]void fToC() { convertPt1 = cel - 32; cel = convertPt1 * (5.0f/9.0f); }[/code] [b](5.0f/9.0f)[/b] Was changed from [b]5/9[/b] because of something someone else said. I tried it, and it still doesn't work. My question? How do you declare it as a fraction(5/9ths), or is there something else to do? If I'm not making any sense, I can try and rephrase everything. I'm still new(ish).[/QUOTE] is cel an int?
[QUOTE=ZeekyHBomb;32256516]What's the problem?[/QUOTE] Well, when I run it it doesn't accept the 5/9 as a fraction. It just divides whatever convertPt1 is by 5/9. Like, when the answer should be 140, it shows 32. [editline]12th September 2011[/editline] [QUOTE=Richy19;32256542]is cel an int?[/QUOTE] What does it need to be?
[QUOTE=Werem00se;32256575]Well, when I run it it doesn't accept the 5/9 as a fraction. It just divides whatever convertPt1 is by 5/9. Like, when the answer should be 140, it shows 32. [editline]12th September 2011[/editline] What does it need to be?[/QUOTE] a float or a double
[QUOTE=Richy19;32256616]a float or a double[/QUOTE] Okay, I fixed that. It still gives me 32 instead of 140. But this time with 32.222.
Just post the code
can you show all your code
So Im trying to make a screen shot tool that works like Gyazo(without the uploading). I basically have it working. It cuts out the area that you put a rectangle around, but it basically crops it out of the full desktop. So you have a ton of white space around what you took a picture of. It keeps the original size of the screen but just removes everything except what you choose. So I need to figure out how to either change the final image so the part that was cut out is in the top left corner, or not make that happen in the first place. Heres the code: [code] public partial class frmScreen : Form { bool mouseIsDown = false; int startX, startY, endX, endY; public frmScreen() { InitializeComponent(); } private void frmScreen_MouseDown(object sender, MouseEventArgs e) { //Get point startX = e.X; startY = e.Y; } private void frmScreen_MouseUp(object sender, MouseEventArgs e) { endX = e.X; endY = e.Y; //Take image, save it //I found this part online, I just changed around g.CopyFromScreen so it would copy a certain area instead of the entire screen. Rectangle selectedArea = Screen.GetBounds(Point.Empty); using (Bitmap bitmap = new Bitmap(selectedArea.Width, selectedArea.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(new Point(startX, startY), new Point(endX, endY), new Size(Math.Abs(startX - endX), Math.Abs(startY - endY))); } bitmap.Save("F:\\test.jpg"); } Application.Exit(); } }[/code] I tried changing: [CODE] Rectangle selectedArea = Screen.GetBounds(Point.Empty);[/CODE] to the rectangle of the area selected, but that just results in a white box the size of the area I selected. Although it is in the top right corner. I tried a bunch more stuff but cant seem to get it. Any help would be great. Edit: C# btw.
Yeah, here it is. It's not done, but it runs right now. I'm sure it's just some stupid mistake that is going to make me feel like an idiot. [code]#include <iostream> using namespace std; char whatIsConvert; //variables double cel; double fer; double convertPt1; double convertedNum; //function definitions void fToC() { convertPt1 = cel - 32; cel = convertPt1 * (5.0f/9.0f); } int main() { cout << "Welcome to a converter program.\nYou can convert Celsius(c) to Fahrenheit(f), or reverse.\n"; cout << "What do you want to do?: "; cin >> whatIsConvert; if (whatIsConvert == 'c') { cout << "You have choosen to convert Celsius into Fahrenheit.\n"; cout << "Enter the tempature in Celsius: "; cin >> cel; fToC(); cout << "The temperature is: " << cel << "."; } system("pause"); return 0; }[/code]
snip hmmmm
[QUOTE=Werem00se;32256985]Yeah, here it is. It's not done, but it runs right now. I'm sure it's just some stupid mistake that is going to make me feel like an idiot. [/QUOTE] It is because to convert from C to F you need to do: [code]°C x 9/5 + 32 = °F[/code] You are doing F to C
You are converting from Fahrenheit to Celsius, NOT Celsius to Fahrenheit [editline]12th September 2011[/editline] haha
[QUOTE=Werem00se;32256985] I'm sure it's just some stupid mistake that is going to make me feel like an idiot. [/QUOTE] Knew it. :v: Thanks though!
A highly noob C++ question: I have a 2d bool array. I want to write a function that returns how many neighbour cells are set to true. Is there a better way to do that other than making 8 if statements?
[QUOTE=Werem00se;32257255]Knew it. :v: Thanks though![/QUOTE] I cleaned up your code a bit: [cpp] #include <iostream> using std::cout; using std::cin; //function definitions double CelsiusToFahrenheit(double celsius) { return (celsius/ (5 / 9.0))+ 32; } int main() { char conversion; //variables double input_value; cout << "Welcome to a converter program.\nYou can convert Celsius(c) to Fahrenheit(f), or reverse.\n"; cout << "What do you want to do?: "; cin >> conversion; if (conversion == 'c') { cout << "You have choosen to convert Celsius into Fahrenheit.\n"; cout << "Enter the tempature in Celsius: "; cin >> input_value; cout << "The temperature is: " << CelsiusToFahrenheit(input_value) << "."; } system("pause"); return 0; } [/cpp] I left in the system("pause") because I don't know what to replace it with, (I don't ever have the need to stop the program in this way) but note that it's generally considered bad practice to use it, due it's unportability and how it's sorta like killing an ant with a nuke. I would recommend just deleting it and running the program through the command prompt. Or changing your settings in your IDE so the window doesn't close.
[QUOTE=Mikolah;32257426]A highly noob C++ question: I have a 2d bool array. I want to write a function that returns how many neighbour cells are set to true. Is there a better way to do that other than making 8 if statements?[/QUOTE] [cpp]inline int b2i(bool b) { return b ? 1 : 0; } int neighbourCount = b2i(upLeft) + b2i(up) + b2i(upRight) + b2i(midLeft) + b2i(midRight) + b2i(bottomLeft) + b2i(bottom) + b2i(bottomRight);[/cpp] (Protip: Pretty dumb solution, whether it's better than 8 if statements is up to you)
[code] int neighbors=0; for(int X=-1;X<=1;X++){ for(int Y=-1;Y<=1;Y++){ if(X!=0&Y!=0&pixels[X][Y]) neighbors++; } } [/code] Untested
[QUOTE=Map in a box;32258080][code] int neighbors=0; for(int X=-1;X<=1;X++){ for(int Y=-1;Y<=1;Y++){ if(X!=0&Y!=0&pixels[X][Y]) neighbors++; } } [/code] Untested[/QUOTE] [cpp]int neighbours = 0; for(int x = -1; x <= 1; x++) { for(int y = -1; y <= 1; y++) { if(x != 0 && y != 0 && neighbours[x][y]) neighbours++; } }[/cpp] ftfy As well as de-obfuscating :v:
How can I get the appropriate direction to push an object out of a tile (collision response). Could I use the velocity or maybe hold the object's previous position? The way I did it in the past was to get four floats and see which one was the shortest - and push the object out that way, is this a viable option?
I think this is slightly better, since it won't have to check X and Y each iteration: [cpp]int neighbours = boolarray[x][y] ? -1 : 0; const int endX = x + 1, endY = y + 1; for(--x; x <= endX; ++x) for(--y; y <= endY; ++y) if(boolarray[x][y]) ++neighbours; return neighbours == -1 ? 0 : neighbours;[/cpp]
I've been trying to get a program to compile under C++ for a while, using Overv's glext.h and wglext.h from his [url=open.gl]website[/url], but I keep getting the error "'glUniform1f' was not declared in this scope", even though if I go to glext.h I can see the declaration of the function. [cpp]#define GETPROCADDRESS_( func ) wglGetProcAddress( func ) #define GETPROCADDRESS( func ) func = ( decltype( func ) )GETPROCADDRESS_( #func ) #include <windows.h> #include <gl/gl.h> #include <gl/glext.h> int main( int argc, char** argv ) { GETPROCADDRESS( glUniform1f ); return 0; } [/cpp] It's probably something silly (Yes, I do have all of the libraries set up to link and such, etc, etc.), but thanks if you can help. (And do!) [editline]...[/editline] I also realize that I need a context and all that, but it doesn't realize that the 2.0 functions and up even exist, I believe.
It would seem that you need to define GL_GLEXT_PROTOTYPES before including glext.h, or declare glUniform1f yourself.
[QUOTE=Whitewater;32259343]I've been trying to get a program to compile under C++ for a while, using Overv's glext.h and wglext.h from his [url=open.gl]website[/url], but I keep getting the error "'glUniform1f' was not declared in this scope", even though if I go to glext.h I can see the declaration of the function. [cpp]#define GETPROCADDRESS_( func ) wglGetProcAddress( func ) #define GETPROCADDRESS( func ) func = ( decltype( func ) )GETPROCADDRESS_( #func ) #include <windows.h> #include <gl/gl.h> #include <gl/glext.h> int main( int argc, char** argv ) { GETPROCADDRESS( glUniform1f ); return 0; } [/cpp] It's probably something silly (Yes, I do have all of the libraries set up to link and such, etc, etc.), but thanks if you can help. (And do!) [editline]...[/editline] I also realize that I need a context and all that, but it doesn't realize that the 2.0 functions and up even exist, I believe.[/QUOTE] Shouldn't glUninform1f be a static and global function pointer, and getprocaddress returning a pointer to the function, while taking "glUninform1f", a string, as an argument?
Sorry, you need to Log In to post a reply to this thread.