- Upvotes Received
- 4
- Posts with Upvotes
- 2
- Upvoting Members
- 4
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
Student
51 Posted Topics
Re: To use the time as the seed is very simple. Make sure you include the <ctime> header. [code] #include <ctime> [/code] Then, inside ctime there is a function you can call like this: [code] time(0); [/code] When you pass this method zero, it returns the time elapsed since January 1, … | |
[B]Introduction[/B] Hello everyone. This little code snippet shows you how to read in scan codes from the keyboard. It is slightly different than reading in a regular character. When you use the [INLINECODE]getch()[/INLINECODE] function, it is normally returning an ASCII value. Some keyboards have extra keys though. These include the … ![]() | |
Re: I like this snippet. I always find this kind of C++ code very useful. | |
This code snippet actually contains a few nifty things. There are two functions, hasVisited() and main(). hasVisited() makes use of a very handy function for CGI programmers: getenv. You can see I use it to retrieve REMOTE_ADDR which is the person's IP address. In main() it gets the count from … | |
This snippet shows how to use command line arguments as variables in your program. A command line argument is extra information you give a program at runtime, by typing the information after the program name like so: Linux might look like this: user$: ./myprogram argument1 argument2 A windows command prompt … | |
I've been trying to solve this problem for a while now with no luck. I want to monitor an input buffer(cin) for a keypress. The catch is, I don't want it to hang if the buffer is empty. [INLINECODE]getch()[/INLINECODE] and [INLINECODE]peek()[/INLINECODE] won't work because one waits for a keypress and … | |
I'm writing a Win32 application for Windows XP with Visual Studio 2005. It is a console program, and I'm trying to find the HWND attribute of my console. I need this because I need to use it as a parameter for a function. So, thanks to the MSDN library I … | |
I think it is unfair to stick the Ruby discussion forum inside Web Development. Ruby on Rails is a really handy web framework, but Ruby has other capabilities. I think it should be put under Software Development, does anyone agree? | |
Hi, I'm trying to write a program using named pipes, and I'm having trouble opening it. In another program I call this line: [code] mkfifo("./fife", 0777); [/code] So my named pipe exists and I see it in my list of files. Then I run the program I included below, but … | |
Re: Hey zellex, I wrote a connect 4 AI agent a while ago. You can play it at [URL="http://students.csci.unt.edu/~jdl0107/conn4.exe"]http://students.csci.unt.edu/~jdl0107/conn4.exe[/URL] I know our code is different, but this is a link to my source code for my AI: [URL="http://students.csci.unt.edu/~jdl0107/leon.cpp"]http://students.csci.unt.edu/~jdl0107/leon.cpp[/URL] You are welcome to look through it. My leon::move method is the one … | |
When programming with pthreads, you pass the thread a function to run when you create it. When this function is done, is the thread cleaned up automatically? Is it necessary to put [inlinecode]pthread_join()[/inlinecode] in the calling function somewhere? Is [inlinecode]pthread_join[/inlinecode] only useful when you want to [I]wait [/I]for a thread … | |
I've been trying to find a function that returns the version number of the JVM. I found this website that does it, so I know it can be done: [url]http://www.javatester.org/version.html[/url] Can anyone help me out? | |
I need to research ways to run a diagnostic check on a user's browser. This includes [LIST] [*]Cookies enabled [*]Javascript available and version [*]Pop-up windows enabled [*]Javascript available and version [*]Flash available and version [/LIST] If anyone has any tips on how to integrate all of these checks on a … | |
Do you think it is OK for a supervisor to fire an employee for getting a call from another company they applied for? Is it standard business practice to call someone's current employer to ask about them? | |
Is there any way to read or write to a socket besides using the [inlinecode]read()[/inlinecode] and [inlinecode]write()[/inlinecode] functions. Is there any way to treat it like a stream and use the insertion/extraction operators (<< and >>)? The reason I ask is because with read I have to put an arbitrary … | |
Is it possible to have a perl script and a bash script in one file? Like: [code] #!/bin/perl print "This is perl"; #exit perl #!/bin/bash echo "This is bash" exit 0 [/code] This is probably just a complicated solution to a simple problem. I have a perl script, and at … | |
I have a very specific problem. Does s/// work with strings that are contained in single quotes? I've been debugging and I'm trying to replace a string that contains a $ in it. If I use double quotes, it works for the string up until the $. If I use … | |
I'm trying to create a general buffer that I can use in my program. It will work with ints as well as strings. So far I've been using a strstream, and it works without a hitch, but I was wondering if there is a way to just create a generic … ![]() | |
I am working with form processing and text manipulation, and I found two useful functions; tr/// and s/// They do pretty much the same thing, but I was wondering if anyone could explain to me what the difference is and if one would ever be more useful than the other … | |
Hi, I'm trying to write a simple Queue class, but I'm having trouble using it. It tells me I have undefined references to the functions I call in main. [code] // main.cpp #include <iostream> #include "queue.h" void main() { Queue<int> myq; myq.push(10); std::cout << myq.isempty() << endl; myq.makeempty(); std::cout << … | |
Re: If you want to connect to your own network by going outside and coming back in you need to know your external IP address, and you need to tell your [I]router [/I]to forward your port(1234) to your server computers internal ip address. Then using your client side code try to … | |
Re: depends what operating system you have. on linux type chmod +x myscript.pl in windows...i dont think it differentiates files that are executable and text files except by the extension, which is .exe | |
Does anyone know where I can find the pthread library for Linux? And I don't want any rude "go google it" responds. I tried that, and all I came up with was one download available for win32. | |
Re: Acquire, The first thing I noticed was this [inlinecode]char names[99][28]= {" "};[/inlinecode]. If you get an error with that line, try using single quotes instead of double quotes. Double quotes are associated with strings, while single quotes are for char's, which is what you are using. It should look like … | |
I'm trying to get into some practice with Mesa GL and I know it works for the X desktop. Will it work the same with Gnome or KDE? Are those based off of X? | |
Re: I think the problem is because when you declare a variable static it affects the lifetime of it. You declare it inside the If brackets { }, so it will be destroyed at the end of the if statement. But, the static variable probably doesn't want to go away. It … | |
Re: I compiled your latter source code, and it worked fine. I could input the four numbers and it would give me output. You say it quits before it outputs the text? If you are using Visual Studio, if you run the program normally in console mode, it will close after … | |
Is there a way to set global hot keys? I want to be able to run a program using a hotkey like CTRL-F12 or something. Any ideas how to do that? | |
I have a question and I was hoping someone could point me in the right direction. I know the IP address of a server I want to download a file from, and I know the path on the client hard disk I want to download it to. How could I … | |
Have any of you competed in the topcoder matches? Have you found them helpful? | |
Re: I am a college student right now and I do almost all of my school coding with JOE on linux systems and compile with g++. I've also had to use Visual Studio 2003, which did make it easy to debug. I prefer the text editors and the command line because … | |
When someone accesses a cgi script in their web browser is there a way to gather information, like IP address or user's web browser? I know how to read command line arguments, but I have a feeling that isn't how it would be passed via the web. Maybe someone can … | |
Ok, I have a small problem. I'm just trying to get my program to read a single line from a file at a time, and put the results in a vector. The problem is at the end of each vector. It repeats the last element twice and also adds a … | |
Hi everyone, I have a simple setback in my program. I'm not the best way to go about doing this. I'm trying to do it in the simplest way possible. I have an input file that looks like this 2.5 600 -2 10 20 30 I want to sort each … | |
I have been writing some CGI scripts in C++, and I was wondering if anyone else has done the same? I have built a pretty decent sized library of functions I use a lot for formatting form inputs and such. The reason I chose C++ is because I'm so familiar … | |
Re: This is a code snippet I wrote about keyboard input. It includes a demonstration of the arrow keys being read. [url]http://www.daniweb.com/code/snippet497.html[/url] | |
Re: WolfPack is correct if you want to put the name of the file into your code. From the post, I read that you wanted to pipe a file into it. It would help if you posted your operating system. This is out you can pipe files on a Linux machine: … | |
Hi, I'm using Windows XP Pro. I haven't had to do this since I used MS-DOS and I don't remember how: I have a utility program that I want to be able to run from the command prompt, but in any directory. Is there a specific directory to stick things … | |
I've been looking for information on threading, and I found information on POSIX pthreads. Apparently, Visual Studio 2005 does not have [INLINECODE]pthreads.h[/INLINECODE] in their library. I did a search on the computer, and I found pthreadlocale.obj in the LIB directory. Does this object file have anything to do with pthread.h? … | |
Hi, Let me explain a little background of the situation in case there is a wiser solution than vectors. I've got a loop running in a program, and for each loop, I need to add a new element at the end. I need to backtrack anywhere from 5 - 250 … | |
Re: [URL="http://www.gamedev.net"]Www.gamedev.net [/URL] has some useful stuff for interested game developers. | |
Re: To get the address of the pointer depends on how it was initialized. If it was initialized as a pointer: [code] int* int_ptr; [/code] To send the address to an ostream just use [inlinecode] out << int_ptr; [/inlinecode] If you don't have a pointer, but only a variable: [code] int … | |
Hey everyone, I'm trying to write a simple program that can do more than one thing at once. I'm not an expert on the iostreams, so I don't know if I need to create threads to accomplish what I want. What I'm trying to do is run a loop while … | |
Hey, I have a problem using Visual Studio 2005. In the MSDN library it says there is a function called SetConsoleDisplayMode. This function though is not in the 2005 library. I'm assuming its an old reference from VS 2003. Does anyone know how to tell a console program to switch … | |
Re: The problem is with the hello variable. When you write [code] int *hello; // What you're saying is create a pointer called hello. // When you write cout << hello; // hello will be some arbitrary hexadecimal number(a memory address) // When you write cout << *hello; // *hello = … | |
Re: Well, I'm not sure about everything you need to do in the program but there are a few things I noticed. As the other reply says, your loop for the array should go from 0-4, not 1-5. After all of your if statements you have two lines of code. If … | |
Re: A good way of finding the highest of X number of integers is to use vectors, and to use the sort algorithm. They are both from the Standard Template Library STL. I'll give you an example of how to use it, but you will need to modify loops and such … | |
I was just curious is anyone has ever programmed a AI agent for Connect 4. I'm currently working on one right now for a class. I'm working on using backtracking/recursion to solve it. If you have, did you use recursion? Just curious what other methods are out there. I am … | |
I had the idea in my head to write a program that would let you select more than one image you want to set as your windows desktop wallpaper and have it rotate it every day, or every time you boot up or something similar. I really don't know where … |
The End.