Forum: C++ Oct 24th, 2009 |
| Replies: 24 Views: 63,601 Write a program that gives the weekday you were born.
Write a program that tells you many days old you are.
Write a program that lists the date of the third Wednesday of the month for the whole... |
Forum: C++ Mar 28th, 2008 |
| Replies: 3 Views: 12,978 This is really C++ syntax. |
Forum: C++ Jun 4th, 2007 |
| Replies: 6 Views: 2,444 You might have to add the line
using namespace std;
or add a std:: before every cout and cin (etc).
What are you using for a compiler? Sounds like the old Borland thingy! |
Forum: C++ Jun 4th, 2007 |
| Replies: 47 Views: 7,617 Java and Python are much alike, they both compile to virtual machine code (byte code) and then interpret this code to the specific CPU machine code.
Java uses pretty much the same ugly syntax... |
Forum: C++ May 25th, 2007 |
| Replies: 4 Views: 12,524 Thanks for moving it to C++, whoever did it. |
Forum: C++ Mar 1st, 2007 |
| Replies: 5 Views: 1,157 I used a similar library for Delphi and it worked well. Here is the C/C++ counterpart.
"Windows Std Serial Comm Lib for C/C++" (includes XP), a shareware download from:... |
Forum: C++ Feb 25th, 2007 |
| Replies: 22 Views: 26,511 You have two separate programs, so you might have to create two separate projects. |
Forum: C++ Feb 9th, 2007 |
| Replies: 4 Views: 5,821 I think his TA would look right through that as somebody else's fairly sophisticated code! |
Forum: C++ Feb 9th, 2007 |
| Replies: 16 Views: 3,343 There is an open source project called MONO that allows .NET stuff to be run on the Linux operating system. I think the name MONO came from the effort to break the attempted MicroSoft monopoly. |
Forum: C++ Feb 1st, 2007 |
| Replies: 2 Views: 2,887 If you Google "Convert C++ to Java", you get 1,770,000 hits with plenty of tools available in the first ten hits. If those tools are perfect in every case, I don't know. Take a look! |
Forum: C++ Jan 31st, 2007 |
| Replies: 2 Views: 1,174 Generally one would use Windows API function SetPixel(hDC, x, y, color). For an actual example see:
http://www.daniweb.com/code/snippet217.html |
Forum: C++ Dec 31st, 2006 |
| Replies: 49 Views: 8,433 Just a note, cin.sync() is not considered to be very reliable for removing vagabond '\n' characters.
No wonder the poor chap through in the C++ towel. |
Forum: C++ Dec 23rd, 2006 |
| Replies: 4 Views: 5,641 Glad to see someone is interested in music! You can simplify your code a little by calculating the frequency for a given musical note. See this snippet:
http://www.daniweb.com/code/snippet359.html
... |
Forum: C++ Nov 20th, 2006 |
| Replies: 4 Views: 1,565 If you are running Windows, check this code snippet:
http://www.daniweb.com/code/snippet83.html |
Forum: C++ Nov 4th, 2006 |
| Replies: 20 Views: 4,793 A nice style guide for C/C++ code:
http://www.gidnetwork.com/b-38.html |
Forum: C++ Oct 18th, 2006 |
| Replies: 13 Views: 3,144 The & is missing from keyboards in a number of European countries, as is the $ symbol. They however have other symbols they need on their keyboards. |
Forum: C++ Oct 16th, 2006 |
| Replies: 13 Views: 3,144 The C compiler that comes with Dev-CPP must be more modern ...
// using "and" and "or" rather than "&&" and "||"
// as a Dev-Cpp C project
#include <stdio.h>
#include <iso646.h> // yes this... |
Forum: C++ Oct 16th, 2006 |
| Replies: 13 Views: 3,144 Again, it depends on which country you live in. Not all keyboards have a & key!!!! Actually "and" looks a lot more readable than "&&". Dev-C++ uses a much more international open source GNU... |
Forum: C++ Oct 10th, 2006 |
| Replies: 10 Views: 8,759 For something like a dictionary sized array of strings I would use a combination of sorting routines with look-ahead. Something Narue's snippet "Optimized quicksort implementation" shows:... |
Forum: C++ Oct 9th, 2006 |
| Replies: 4 Views: 3,583 PlaySound() does not play midi files, use mciSendString() to play a midi music file. Check the details in cpp code snippet:
http://www.daniweb.com/code/snippet118.html |
Forum: C++ Oct 8th, 2006 |
| Replies: 9 Views: 1,632 Take a look at function fscanf() that delimits on whitespaces. Nothing wrong with using it in C++, it is part of ANSI C++. |
Forum: C++ Oct 2nd, 2006 |
| Replies: 16 Views: 9,957 The way I feel, with Python you drive the car, and with C++ you fine_tune the carburetor and adjust the gears. Well, sometimes it's fun to get your hands dirty! |
Forum: C++ Oct 2nd, 2006 |
| Replies: 15 Views: 30,130 You can change the speed in this commented line:
// 50ms here, lower value gives higher speed
SetTimer((HWND)Form1,1,50,NULL); |
Forum: C++ Oct 2nd, 2006 |
| Replies: 16 Views: 9,957 I went with the second option and inserted ...
if (dV.empty())
{
cout << "... cannot process an empty vector so I made one up:\n";
dV.push_back(99.9);
dV.push_back(7.1);
... |
Forum: C++ Oct 2nd, 2006 |
| Replies: 16 Views: 9,957 Great, thanks ~s.o.s~ I finally was able to get rid of the old eyesore system("pause"). I knew there were stray '\n' around, but even the old double cin.get() trick didn't work here. Strangely... |
Forum: C++ Oct 2nd, 2006 |
| Replies: 4 Views: 31,549 Thanks keithr, for making the code work with VisualStudio.Net (2003). Looks like different compilers have somewhat different header requirements. Oh the joy of C++ headers!!! |
Forum: C++ Oct 2nd, 2006 |
| Replies: 16 Views: 9,957 I agree with you, cin.get() is the portable way to wait, but take a look at a small code snippet I wrote a long time ago:
http://www.daniweb.com/code/snippet105.html
I would love, if you could... |
Forum: C++ Oct 2nd, 2006 |
| Replies: 16 Views: 9,957 If you ever used Dev-C++ you would know that much of this code comes up as a templet. My point was to show how to use the Sleep() function. Talking about heavy overhead, the iostream header creates... |
Forum: C++ Oct 2nd, 2006 |
| Replies: 13 Views: 2,953 If you are talking about the SetPixel() snippet, that is a Console Application in Dev-C++ parlance. Windows Applications are fullblown Windows GUI programs with frames, buttons, labels, event loops... |
Forum: C++ Oct 2nd, 2006 |
| Replies: 16 Views: 9,957 If you are using Windows and Dev-C++ then the function is Sleep(milliseconds) ...
#include <cstdlib>
#include <iostream>
#include <windows.h> // needed for Sleep(millisec)
using namespace std;... |
Forum: C++ Oct 1st, 2006 |
| Replies: 13 Views: 2,953 Hidden in the DaniWeb C++ code snippets is an example of using WinAPI SetPixel() that allows you to put a pixel at the specified x,y coordinates, and also uses the color you give it. The example... |
Forum: C++ May 17th, 2006 |
| Replies: 3 Views: 1,257 Dev C++ is just a nice free IDE that happens to use public domain compilers like g++ and gcc. Rumors about its death are a little premature, and are most likely spread by commercial interests, so... |
Forum: C++ May 15th, 2006 |
| Replies: 8 Views: 2,604 I am using dev-c++ 4.9.9.1 and your last code works just fine (Windows XP). I think the version should not make any difference, that is only an update of the IDE. Are you using g++ as the compiler?... |
Forum: C++ Mar 24th, 2006 |
| Replies: 3 Views: 4,388 This is a C++ program and should be moved to the cplusplus snippets! |
Forum: C++ Mar 18th, 2006 |
| Replies: 2 Views: 15,120 I don't want to step on any C++ toes, but there is a "Projects for Beginners" thread in the Python forum. Much of it is applicable to C++ programmers too. Take a look at:... |
Forum: C++ Mar 17th, 2006 |
| Replies: 5 Views: 3,388 The function clock() in time.h or ctime returns the number of ticks since "process start". A tick is about a millisecond. |
Forum: C++ Feb 7th, 2006 |
| Replies: 3 Views: 9,059 This little while loop will ask for an integer input until it gets one ...
// controlled integer input in C++:
#include <iostream>
#include <string>
#include <sstream>
int main(void)
{
... |
Forum: C++ Feb 6th, 2006 |
| Replies: 9 Views: 4,436 Take a look at the C++ code snippet at
http://www.daniweb.com/code/snippet122.html
You will have to format your text to fit the labels. |
Forum: C++ Jan 17th, 2006 |
| Replies: 6 Views: 3,646 Thank you, that helps a lot! The problem came from Python that seems to balk at more then twenty levels of nesting. Much of the Python interpreter DLL is written in ANSI C.
The actual question... |
Forum: C++ Jan 15th, 2006 |
| Replies: 6 Views: 3,646 Does anybody know the limit of nested for loops in C or C++? If there is a limit, what is the reason? |