4,305 Posted Topics
Re: Just to rehash it all: [php]//REMAIN.CPP updated for Dev-C++ #include <iostream> //necessary for cin and cout commands using namespace std; // takes care of std:: int main() { int dividend, divisor; //get the dividend and divisor from the user cout << "enter the dividend "; cin >> dividend; cout << … | |
Re: Get lots of code samples and compile, run, analyze, experiment and butcher. Set yourself a project goal, write something you are interested in and make it almost perfect! | |
Re: Let's solve this one error at a time, use if (twentynote > 0) hint, conditional statements should be in (). That goes for all your if and while. ... and oh yes, Dev-C++ is very good for student use! | |
Re: Unquestionably line 42, the whole 10x10 2D array is dumped onto the atomic memory pool heap! Not even one bit left! | |
Re: Actually quite an interesting code. After the correction the code will compile. BTW in this case you only need one cin.get() for the console to wait, since there is no enter to trap. At least on my machine there is no effect after using just strcpy(state,"California"); or even strcpy(state,"CaliforniaCalifornia"); but … | |
Re: Imagine this, and it's not even April 1st yet ... I think somebody is trying out the bigots! | |
Re: Narue, with your permission I will make a copy of this and hang it on the wall next to Albert Einstein's famous dictum. | |
Re: Here is some old rehash of mine ... I like C# in Windows Applications, and find the flow of the code much easier to follow than that of the corresponding C++ code . I think of it as Delphi in a classy C++ coat, it has the same chief designer … | |
Re: Are you sure you are running this project as a Windows Application? | |
Re: Load your file byte by byte into a vector of bytes and erase the elements you want. The vector will adjust itself. | |
Re: [QUOTE=freesoft_2000]Hi everyone, Narue you said "COBOL is still used quite a bit 30 years later" Are you living on the MOON? At least the rest of the other guys that post in this thread say something logic. Hey man what's with the name calling?? From your post i think you … | |
Re: If in doubt, you can cast both arguments to double. | |
Re: Professors that don't know how to teach are part of academic life. Get a tutor, or drop the course and hope somebody else will actually know how to teach it later on. | |
Re: Looks like very old Borland code. What compiler are you using? | |
Re: Another trick is to simply trap the enter key with another cin.get() like this: [php] #include <iostream> using namespace std; int main() { int age; cout << "enter age\n"; cin >> age; if (age <= 18) cout << "child\n"; cin.get(); // trap enter cin.get(); // wait return 0; } [/php] | |
Re: If you just want a more readable switch/case, simply use enumerations. [php]// example of enumeration enum name { list, ....... } #include <stdio.h> // in/out and file functions enum days { sun,mon,tue,wed,thu,fri,sat }; // sun = 0 etc. int main() { enum days week; for (week = sun; week <= … | |
Re: [QUOTE=gtsreddy]thanks a lot i will appreciate it also if i want to do image processing , will C++ allow me to do that job[/QUOTE] Just read the image file as a binary file into a buffer and go at it. This means, change some of the bytes mildly, in a … | |
Re: I know this is very old code from the attic and dusted off a little. It might give you a hint or confuse you totally. [php] // read the filenames from a given directory // globals #define MAXFILES 1500 // maximum filenames in buffer char fbuf[MAXFILES][80]; // filename buffer int … | |
Re: What is your question? Are you using the wxWidgets IDE for Dev-Cpp? If not, check: [url]http://wxdsgn.sourceforge.net/[/url] This IDE turns Dev-Cpp into the closest free thing to Visual C++. | |
Re: Narue, finally a good use for --> system("cls"); and you did it without the stdlib.h | |
Re: Sleep(time_in_ms) is a Win32-API function and you might want to include windows.h Make sure you are using Sleep() and not sleep(). | |
![]() | Re: You can load your characters into a vector and use something like: [php]random_shuffle(cV.rbegin(), cV.rend()); [/php] Check out the code snippet on vectors to get an idea how to create and display the vector. ![]() |
Re: I really like Dev-C++, the help file sucks however. There are a number of very helpful sites that cater to questions on Dev-C++. For the language itself, I am using Borland's helpfile instead. Microsoft, Borland 5.5 and Dev-C++ are free on the net. The nice thing about Dev-C++ is that … | |
Re: [php] cout<< "Lees een rij van tien positieve getallen in en bepaal hoeveel van deze getallen" " door 2, hoeveel door 3 en hoeveel door 5 deelbaar zijn! "<<endl; [/php] Anything with that many "van" in it is bound to be Dutch!!!!! If you are not Dutch, you are not … | |
Re: Good luck with your adventures in C++ ... [php]// haids or tails (Dev C++) #include <iostream> #include <iomanip> // for setw(), not used here #include <ctime> #include <cstdlib> using namespace std; // for std::cin, std::cout etc. int main() { int rn; srand(time(0)); for (int counter = 0; counter <= 10; … | |
Re: There are a ton of graphics functions in the Windows API. DirectX and openGL add more stuff! Got to leave those Flinstonian times behind. It's learning time!!! I have googled, have you? | |
Re: [QUOTE=Dave Sinkula][IMG]http://img64.exs.cx/img64/2314/delete3zj.gif[/IMG][/QUOTE] That deletes selected code, not a project or file! Let's try it again ... | |
Re: show_temps() does not walk through the list! | |
Re: You inspired me to add one more item to my code snippet on std::string ... [php] // use \" for embedded double quotes string s1 = "<tr><td><img src=\"log_error.bmp\"></td><td><b>"; cout << s1 << endl << endl; [/php] | |
Re: [QUOTE=1o0oBhP]not having a go, dont worry! just saying that if there is anything that cant be sorted then a few people have discussed the topic of going both ways (b2d, d2b) on a different thread. btw where is the pow function defined ? is it in <cmath>? would certainly simplify … | |
Re: Represents a minimum change to your code, changing NFL to a string and making a string compare in the if statement: [php]// Dev C++ #include <cstdlib> // system() #include <iostream> using namespace std; // std::cout, std::cin int main() { char NFL[20]; cout << "Who is the best team in the … | |
Re: [QUOTE=nvanevski]Besides, you do not have a [B]break[/B] statement for case 3. You need to put [B]break[/B] statements for each case.[/QUOTE] Funny way to do it, but case 4 provides the break for case 3 | |
Re: As Dave mentioned [php] #include <iostream> #include <stdlib.h> using namespace std; int main(int argc, char *argv[]) { cout << "text" << endl; system("PAUSE"); return 0; } [/php] works. Just a reminder, system("PAUSE") activates the old DOS command PAUSE and is not very portable code. There is also a school of … | |
Re: With system() you can access any old DOS command (if you are using Linux, any old Unix command). #include <stdlib.h> ... system("CLS"); // the much debased clear screen system("PAUSE"); // wait, the hard way system("DIR"); // list the directory ... and so on! Not recommended if you want to have … | |
Re: Just a little help ... [php]// pulls the words out of a text stream string get_word(istream& in) { char ch; string s; while(in.get(ch)) { // these characters separate the words if (ch == ' ' || ch == ',' || ch == '.' || ch == '\n' || ch == … | |
Re: Depending whom you work for, there might be a favorite compiler in the shop. Many schools teach on old and outdated compilers, often teachers are most reluctant to change and rewrite their material, the list goes on ... I have found the Dev C++ IDE reasonably generic in the Windows … | |
Re: You might want to look at BCX basic, it actually uses some common C compilers to to make the executable. It has a great help file and lots of nice samples (GUI and console mode). I use it a lot, it works well with Windows XP. Best of all, it's … | |
Re: Replace scanf("%li\n", &thedate); with: scanf("%d", &thedate); This will give you the proper integer value, a leading zero will be stripped of course. You can also check a little code snippet on DaniWeb called "Day of week given a date" under: [url]http://www.daniweb.com/code/snippet65.html[/url] | |
Re: In the 32 bit world integers have a range of: -2,147,483,648 to 2,147,483,647 | |
Re: > #include <iostream.h> > int mergesort; > int main(void) > { > int ar[100]; > > int i, v, len; > > for (i=0; i<100; i++) { > cout << "enter a number (-1 to quit): "; > cin >> v; > > if (v < 0) break; > > … | |
Re: Maybe this will be the repartee, try char instead of int, very old code, but it is Turbo C ... [php] /******************** fararray.c *********************** ** ** Examination of the limits of global variables: ** Behaviour of two large arrays exceeding the 64k limit. ** one far global array + one … | |
Re: Check out: [url]http://www.cplusplus.com/doc/tutorial/index.html[/url] then get yourself a free C++ compiler at: [url]http://sourceforge.net/projects/dev-cpp/[/url] and play with as many code samples as you can fish from the net! | |
Re: One of the ways to encode and decode using the same function is with a bitwise xor. Now you are making it more difficult demanding that the encoded sentence be in characters that are on the keyboard. This little code sample does it using a set pass-key and an exception … | |
Re: [QUOTE=Narue]>i just need someone to point me in the right direction. [code] int main ( void ) { return 0; } [/code] >but the problem is that i need it to subract the highest and lowest numbers then add the remaining numbers left. What have you tried so far? Have … | |
Re: [QUOTE=jwenting]and scrap #include "stdafx.h" as it's not needed... Never understand why MSVC adds that to everything. Also add #include <iomanip> or you'll never get a clean compile. endl is defined there.[/QUOTE] Just a note: [code] // These are from <iomanip> as per [27.6]. Manipulators from <istream> // and <ostream> (e.g., … | |
Re: Look under C at: [url]http://www.programmingtutorials.com/[/url] and: [url]http://gd.tuwien.ac.at/languages/c/programming-bbrown/cstart.htm[/url] | |
Re: [QUOTE=britt_boy]You can use max_element #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(int) { const int len = 3; const int start = 0; double arr[len]; arr[0]= 2.4; arr[1] = 1.2; arr[2] = 3.67; double* first = arr; double* last = arr + len - 1; //get min … | |
Re: I think Borland Turbo C++ has a peek() function to peek into memory, but not into files. It looks to me that you mean to use get() to get a character from the file? I am not quite sure what you want to do after that. | |
Re: Somewhere within your function main() is another function called GetInformation() that is screwed up! This function maybe internal or more likely from a DLL or library. We need to know your compiler, operating system and a code snippet. | |
Re: for C getchar(): // wait, not totally portable for C++ cin.get(); // wait Caveat, if a lose return is floating about, like after an input you might have to double line it. |
The End.