- Strength to Increase Rep
- +7
- Strength to Decrease Rep
- -1
- Upvotes Received
- 5
- Posts with Upvotes
- 5
- Upvoting Members
- 5
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
Re: 2 things: first, arrays are declared like this: [CODE] int array[5]; int array2[] = {1, 2, 3, 4, 5}; [/CODE] not like this: [CODE] int[5] array; int[] array2 = {1, 2, 3, 4, 5}; [/CODE] secondly, when dealing with multidimensional arrays, unfortunately you can't do [CODE] int array[][] = {{1, … | |
Re: everyone gets heckled a bit from time to time, don't let it bother you. Now, per your request regarding the program. I will try to convince you that it is a bad idea for a beginner. 1st. 6month old babies don't learn to drive on the autobahn (take the analogy) … | |
Hi, my mom has a Dell Dimension 4550 that has been running fairly smooth for several years. Recently she tried to install some new DDR ram in to the mobo, and VERY incorrectly seated it. She asked me to look at it (after the fact) cause her computer would power … | |
hey, had a question that I couldn't figure out. I'm writing a program for linux and I need to save things to a person's Desktop. Because of that, I need to know their username. I am aware of the linux commands whoami, id, etc, but they only print the current … | |
Re: [QUOTE=Protuberance;944855]You have two same functions in class [code=cpp] class Object { protected: enum ID {OBJECT, CAVE, MONSTER, WUMPUS, HERO, GUN, BAT}; //maybe it better place outside the class? Coordinates* _my_coordinates; void id(ID id) //first declaration { this->_my_id = id; } public: explicit Object(s_int coordinate_x = 0, s_int coordinate_y = 0); … | |
Re: if I understand correctly, try adding this just before your return statement in "int main()" [CODE] cin.get(); [/CODE] that will wait for you to review the data and press enter before exiting the program. As it is now as soon as it's done with all of it's tasks, it closes … | |
Re: you will also need to define x, y, a, and first before you can use them in main() | |
Re: a couple things I see, first of all, please see the link in my signature for the rules regarding code tags etc, it makes it MUCH easier for us to help you if we can see your code in a comprehensible manner. Second, I don't think this would compile, so … | |
Re: your boolean logic is ill-formed inside of your if statements, instead of [CODE] if(a==R||r) //etc. [/CODE] it should be [CODE] if((a == R) || (a == r)) //etc. [/CODE] how your first logic reads is "if a equals R or if r". how I think you wanted your logic to … | |
Re: > When my try to rebuild my program i m getting this errors 1>Linking... 1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup 1>C:\Users\agaba\Documents\Visual Studio 2005\Projects\car\Debug\car.exe : fatal error LNK1120: 1 unresolved externals 1>Build log was saved at "file://c:\Users\agaba\Documents\Visual Studio 2005\Projects\car\car\Debug\BuildLog.htm" 1>car - 2 error(s), 0 warning(s) … | |
Re: looks like there's a couple things, I don't think that would even compile: comparing a map<int, vector<int> >::iterator to an int inside your loop doesn't seem safe to me. As well as not declaring the map type for your iterator. anyway, see if this is a good starting point: [CODE=c++] … | |
Re: do you mean if you don't explicitly create a constructor in your class, or are you referring to constructor overloading? if it's that you don't explicitly create your own, here's what happens [CODE=c++] #include <iostream> //feel free to give this a test to see for yourself, it should compile ok … | |
Re: I think I know what you're after, try having a variable to hold the totals for each value, something like this maybe: [CODE=c++] #include<iostream> using namespace std; int main() { double b = 2.88; double h = 2.4; double totalBoards = 0; double totalBags = 0; double w; int p … | |
Re: [QUOTE=Leniel;937357]WHAT 12 ? well 12 is suppose to be of the array for DOB[12]. What n? and the n is to save the crn [n] so that it can matched the DOB [12].[/QUOTE] well, that should give you several problems considering you declared DOB to be an array of size … | |
Re: sorry, this is a c++ forum, there is a C# forum located elsewhere on this site | |
Re: the syntax for a do-while loop is this: [CODE=c++] do { //stuff to loop through } while(conditions); //note the colon [/CODE] and maybe consider changing your 'switch' statement to a series of if-else since there's more than 1 or 2 lines of code for each option. I think that's more … | |
Re: your problem is in how you are compiling it. You need to compile each .cpp file separately into objects and then link them all together at the end. Give this a try (my g++ flags are a bit rusty, but I think they're right) g++ -c time1.cpp -o time1.o //compile … | |
Re: [QUOTE=Cloneminds;914396]For some reason, my numbers aren't adding in correctly and it's taking the -1 sentinel value and adding it into the total. [code=C++] // worthless testing.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using std::cout; using std::cin; using std::endl; int main() { int … | |
Re: global variables ARE a bad idea, which is why it's not the only way to accomplish this with a void function. Try passing things by reference: [CODE=c++] void getSales(double &sales); //try this instead //other functions int main() { //declare constant and variables const double RATE = .1; double sales = … | |
Re: give stringstreams a try for converting from string to integer: [url]http://www.cppreference.com/wiki/io/sstream/start[/url] [url]http://www.cplusplus.com/reference/iostream/stringstream/[/url] | |
hello, got a quick question regarding stack overflow (I honestly don't know if this is more suited for a wxWidgets forum, once you see what I mean, but I figured I'd try here first). I was tweaking my linked list class and testing it in a testing harness program I … | |
Re: 2 options for this problem: 1. Add [CODE]cin.get();[/CODE] just before your return. This waits for user input before exiting the program. 2. Run the program manually from a terminal. Then you can see the output even if the program exits ~J | |
Re: I personally generally use an EVENT_TABLE if I have a large number of events for a class ( > 5 or so), but if I only have 1 or 2 I generally use Connect (or I have a complicated gui, lots of enabling/disabling etc). I've just found it to look … | |
Re: an alternative to the explicit initiation, is you could change your while loop to a do-while: [CODE=cplusplus] #include <iostream> #include <ctime> using namespace std; int main() { int random; int guess; srand(static_cast<unsigned int>(time(0))); random = rand()%7+1; std::cout << "Guess my number! (1-7)\n"; do { std::cin >> guess; std::cin.ignore(); if (guess … | |
Re: [QUOTE=fadia;879121] [CODE] for(int i=1;i>=10;i++) for(int i=1;i>=10;i--) }[/CODE] [/QUOTE] besides arrays you should also brush up on for loops... neither of those will even be entered into (seeing as 1 is NOT greater than or equal to 10). For the first loop you'd need to switch it to this for your … | |
Re: [QUOTE=mirfan00;879221] you just declare password as a char ( char password ) . Now compile it it is erorr free. I hope you enjoy it.[/QUOTE] that is assuming their password is something like 'b' or '7' (I hope it's not) and just because something compiles doesn't mean it works ;) … | |
Re: instead of using the ascii codes which would get a bit more complicated when you add numbers because of the disconnect between the codes (since numbers are 48-57 and letters 97-122), why don't you try something like the following as a starting point: [CODE=cplusplus] string random_letter(int length) { const string … | |
Re: in your revised set of code, try removing the following line: [CODE] int main(int, char**); [/CODE] and what global variables are you referring to? | |
Re: code tags really help :) [CODE=cplusplus] std::cout << "k: " << k; [/CODE] or it's really simple to run through that loop in your head... and if you understand what's going on it's even easier to know what the answer is without having to go through the whole loop. | |
Re: so, does that solve your problem or (since you never said what the problem was) is there more? |