537 Posted Topics
Re: [quote] i have to read each line and then copy to a variable.[/quote] Perhaps strtok() may not be the best way to handle this situation (although I guess it can be used using the '\n' newline escape character as a delimeter); however, your goal seems to be to read in … | |
Re: [code] int *x = new int; int y; cout << "X address is: " << x ; cout << "\n\nY address is: " << &y ; delete x; [/code] The first method (x) you are reading from a pointer without dereferencing it. The second method (y) you are using the … | |
Re: Why are you returning 0 from your 'else' conditions..?? why not let processing continue throughout the loop? Stuff like this can cause your program to not work the way you think it will work. | |
Re: [code] #include <iostream> using namespace std; double calculatecharges(double); int main(int argc, char *argv[]) { //Syntax Error Here //double hours; rate; double hours, rate; int x = 0; do { cout<<"Enter number of hours parked: "; cin>> hours; rate = calculatecharges(double hours); cout<< " your parking fee is :" << rate … | |
Re: I believe our friend adrianwx has addressed these issues in his cool DOS console tutorial: [url]http://www.adrianxw.dk/index.html[/url] | |
Re: Looks like ye' have done everything except the graphics... so I will offer ye' up a function for drawing an ascii circle. This code is an algorithm called a,[URL="http://en.wikipedia.org/wiki/Midpoint_circle_algorithm"] "Bresenham circle."[/URL] [code] void DrawCircle(int x, int y, int radius) { int f = 1 - radius; int ddF_x = 1; … | |
| |
Re: Is formating your hard disk and re-installing an operating system an option for you? | |
Re: I guess you can only compare what you have... right? Therefore, list traversal w/ comparison should only be as long as your shortest list. Another option could be to populate the shortest list with a sentinal value so that both lists would be of the same length. | |
Re: Your professor says you have to accept user input as a floating point number, but he has no requirement for storing the variable as a float; therefore, I would simply accept all user input into a c-string (char array) and perform your validation. The following code uses isdigit() from the … | |
Re: Your professor gave you a function free of charge called outtextxy( ). Worst case scenario, why not just call outtextxy() individually for every ascii character that you will to output on the dos console to draw your circle? This may seem inefficient, but here is a way to at least … | |
Re: This guy can do some amazing stuff with the DOS console window.. best tutorial I've seen for become a master of the console: [url]http://www.adrianxw.dk/index.html[/url] I think you'd be interested in, "Win32 Console Applications - Part 6" [url]http://www.adrianxw.dk/SoftwareSite/Consoles/Consoles6.html[/url] | |
Re: are there any guarantees that any id you come up with will unique.. if so, how will you make this determination... | |
Re: I would use C++ to create an 'array of structs'; each struct should contain attributes for class name and for class number. Then create an array of appropriate size of the aforementioned struct object. Populate the array by prompting for user input. | |
Re: When it comes to storing a bunch of records, nothing beats what I like to call an 'array of structs'. First, design a container that you would like to use: [code] stuct record{ string id; string name; double price; int quantity; };[/code] Now that you have a good design for … | |
Re: [URL="http://www.daniweb.com/forums/thread62077.html"]Here[/URL] is a DOS console roulette game with ascii graphics. [URL="http://cboard.cprogramming.com/cplusplus-programming/55983-blackjack.html"]Here[/URL] is DOS console Blackjack game. [URL="http://cboard.cprogramming.com/windows-programming/113615-need-help-bitmap-display.html"]Here [/URL] is a Blackjack windows app. | |
Re: Try using the <ctime> library: [url]http://www.cplusplus.com/reference/clibrary/ctime/time/[/url] code for a 3 second delay: [code] time_t start_time, cur_time; time(&start_time); do { time(&cur_time); } while((cur_time - start_time) < 3); [/code] | |
Re: The use of a loop may not be warranted in this situation. It seems to me the code is procedurally linear; get user input, perform error checking, test user input, provide output with correct answer. Using a loop, whether it be while, do/while, or for is usually implemented when several … | |
Re: Here is a good tutorial on using strtok(), it's written in C, but that's what you get for using c-strings teehee [url]http://cboard.cprogramming.com/cplusplus-programming/60924-cstring-algorithm-what-do-you-think.html[/url] it offers this example: [code] /* strtok example */ #include <stdio.h> #include <string.h> int main () { char str[] ="- This, a sample string."; char * pch; printf … | |
Re: I don't have a compiler on me' laptop here.. but at first glance everything seems to look ok... Q: how do you know it's not returning the proper value? I see no evidence of any output to determine the return value of number_right( ). | |
Re: I'm not sure of the relevance of Python in today's modern IT world.. but my advice is to spend at some time and do a local job search for software engineers. In my experience, most companies want software engineers that are good in all areas: website design, databases, C, C++, … | |
Re: [code] if (StatsChange == "Strength" or "strength" or "str" or "STR" or "Str") [/code] should be: [code] if (StatsChange == "Strength" || StatsChange == "strength" || StatsChange== "str" || StatsChange== "STR" ||StatsChange== "Str")[/code] I know, believe me I did the same thing when I first got into boolean logic.. because … | |
Re: The most popular method of delay is to use the Sleep() function, a member of the <windows.h> library. | |
Re: I would probably use C++ to write a program that would accept user input, compare to an existing 'database' of information (which you could probably load from a .txt file for example) then output the result. | |
Re: [url]http://www.cplusplus.com/reference/clibrary/cstdlib/srand/[/url] | |
Re: I would use c++ to prompt the user for 10 integers. Each entry could be stored in an array of integers. At this point, you could display a menu of options on how the user would like to sort the array; which sorting method to use, and to sort either … | |
Re: Are you feeling lucky... I'm gonna go all-in on this; I've written a few ascii table games so I know what ye' are talking aboot here. There are of course many ways to do this. I would suggest to write specific functions to test every possible winning situation that can … | |
Re: I would use c++ to design a menu type structure. You should display a menu using iostream objects, such as cout. After your menu is displayed, you should prompt the user for a menu choice. One structure in mind that lends itself to handling menus is use of the switch( … | |
Re: Now that you are using <string> class objects, it is time to unlock the magic of the almighty string. Here is a list of string object members: [url]http://www.cplusplus.com/reference/string/string/[/url] On of them that you may find of particular interest is the find( ) function, which will return the element position of … | |
Re: You are forcing it to write... [code] for (counter=1;counter<=10;counter++) [/code] A preferred method of reading a file: [code] while(infile >> lastname >> firstname) { .... ..... ...... etc. etc. etc. }[/code] | |
Re: This simple change might help ye' [code] char name[80]; [/code] This array of chars (also known as a C-String) will provide you with 79 available char-containers in which ye' can populate with ascii characters. Remember, with c-strings to always make sure you have a '\0' NULL terminator somewhere in your … | |
Re: Luckily for you, the c++ standard provides you with the tools necessary to open, read, and write to files. You can use these tools by including the <fstream> library. Then you can create ifstream objects that will allow you to open and read from a file, and ofstream objects that … | |
Re: Let's break down your problem step by step: PROBLEM: Write a program that reads a series of numbers (doubles) from the user, then prints the mean and the range. • You do not know ahead of time how many numbers will be in the list. At this point in your … | |
Re: Hello mcap61, Forgive me in advance as I do not have a compiler on this laptop; I cannot compile your code thus far, but will attempt to give you the best help that I can... take it for what it's worth. One thing I notice, is you only create one … | |
Got my woman a laptop for xmas... now i don't know what type of router to get. Is there a way to check whether the machine supports wireless G? This is the closest answer I got whilst googling: [url]http://au.answers.yahoo.com/answers2...3185712AA3ycuJ[/url] This states that wireless N is backwards compatible with G, but … | |
Re: [code] #include<windows.h> #include<iostream> #include<cctype> #include<cstdlib> #include<ctime> using namespace std; class Roulette { public: Roulette(); void board_display(); void prompt(); void bet_menu(); void place_bet(); void set_bet(int choice); void set_bet(int menu_choice, int number, int amount); void set_chip(int); void set_chip(int, int); void spin_the_wheel(); void win_or_lose(); void reset(); bool quit(); void gotoxy(int x, int y); … | |
Re: Including the [URL="http://www.cppreference.com/cppio/index.html"]<fstream>[/URL] library will give ye' the tools you need to read and write to a file. Specifically, creating an object of type 'ofstream' will allow you access to library functions that write to a file. | |
Re: [QUOTE=xerenist;438992]i don't know if it allowed to ask like this,, but this triangle make me confused(coz i'm new in C++) but,can u teach me how to make it?/explain how am i supposed 2 do? the triangle is like this: [code] 1 2 3 4 2 3 4 5 6 5 … | |
Re: [code] #include<windows.h> #include<sstream> #include<string> using namespace std; /* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); /* Make the class name into a global variable */ char szClassName[ ] = "calculator"; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HWND hwnd; /* This … | |
Re: [i][u]edit:[/u] This is in c++, so replace 'new' with 'malloc()', 'delete' with 'free', and cout/cin with printf()/fgets()[/i] instead of creating an array of structs like contact[u], 1. create a pointer of type 'contact' 2. everytime you need a new 'contact' node, create it by calling [inlinecode]contact *cntcPtr = new contact; … | |
Re: Look at your output table.... do you see anything in your code you could use as a counter? [i](hint: your days are numbered)[/i] | |
Re: it is possible you could use a default constructor to set the fields of your object: [code] struct proceso { char name[20]; char memory[10]; char time[10]; char files[10]; //constructor [b]proceso();[/b] };[/code] [code] //Function Definition proceso::proceso() { strcpy(name = Doom3); strcpy(memory = 1212); strcpy(time = 14); strcpy(files = 2); }[/code] The … | |
I am going through some book assignments.. and I am running into some terminology that doesn't make sense to me.. [quote] Impelement this class... Class Cis Float Cisfloat a("325.12315"); a+b a * b [b]14 (exp # bits) 113 (sigment # bits)[/b] 10000........0 bias[/quote] what does the author mean by, "exp … | |
Re: what compiler are ye' using? for most IDE's like Dev CPP and MSVC++ 6.0, there is an option to, "add to project".. make sure the you are adding all 3 files to your project, then try to compile. If you are using a command line compiler like borland, you will … | |
Re: If you think about it, any multi-demensional array is in essence a 1D array.. If you have ever studied assembly language you would know this is true. My opinion would be to just keep your 3D array, and access everything through a 1D array subscript. You could access every element … | |
Re: I think ye' problems start here: [code] while (str !='\n' && [b][color=blue]thearray!="model="[/b][/color]) //set all values of thearray to bigarray until its end of line or "model=" { thearray[i] = bigarray[i]; i++; }[/code] If you were using <string> class objects, you would able to make the != comparison. However, the only … ![]() |
The End.