- 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
52 Posted Topics
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? | |
hey, got a quick question regarding template classes. I've made several data structures that I've found to be very useful (using template classes) but it's getting tiresome making a new explicit specialization every time I implement it in a new way. Such as if I want to do this in … | |
hey, I got a question regarding functions returning a linked list. Here's the data structure of my linked list (just in case it deviates from the standard way of doing it) [CODE] template <class T> class Link { private: unsigned int size; Link<T> *nextRow; Cell<T> *firstCell; public: Link(); ~Link(); //functions … | |
hello, quick question regarding template classes and pointers. I'm making a linked list kind of container system, and I'm running into trouble with it when I (don't know if the terminology is 100% correct here) declare an instance of it. An example would be best to explain what's happening: I … | |
hey, I've been thinking of building a new computer for myself for a while and I figure I might as well get started on researching what's new. I've been looking around the web and any site I find that compares amd vs intel is always (understandably) just testing their new … | |
Re: function declarations must be declared before main(), not inside. [CODE] int main() {//begin main double hypot(double,double); .... [/CODE] should be [CODE] double hypot(double, double); int main() { ... [/CODE] give that a try ~J | |
hello, for one of my programs I need to acquire the decimal off of a number, for example, if a double has value of "123.45" I need an int to have the value "45". to do this, I have the following code [CODE] double value, tempValue; int decimalValue; value = … | |
hello, I wrote an expect script to automate ssh commands, and it was working, but for some reason it's not anymore. Just to make sure I didn't do any weird changes that I didn't notice, I tried several of the dozens of such scripts that are online, and for some … | |
Re: [QUOTE] It instantiates two arrays, d with 5,000 elements and f with 5,000 elements. [/QUOTE] I think it's important to note that the 2 arrays are of type "data". [CODE] struct data { int x,y; double s,w,e,d; }d[5000],f[5000]; [/CODE] is equivalent to [CODE] struct data { int x,y; double s,w,e,d; … | |
| |
Re: edit: my fault for not noticing this was addressed in the above post, but I suppose a little more explanation why wouldn't hurt :) this line of code: [CODE] while (a != 'Q' || a != 'q' || a != 'R' || a != 'r') [/CODE] is essentially a [CODE] … | |
hello, been googling this for a while and can't come up with anything good, so hopefully this won't be so easy to answer that it makes me look lazy. I'm writing an application for linux (gcc compiler) that calls various system and custom commands from inside my own program, nothing … | |
Hey, I've been trying to work with wxwidgets so I can start learning GUI's, problem is, it seems like all their libraries are full of errors. I have a hard time believing that a self-respecting group of people would release, as stable, something that would take hours, if not days, … | |
Re: That was a hugely unhelpful reply, I apologize knewc. now, as for your question. to make things lowercase I recommend looking into the function "tolower" As for the removing punctuation, replace() should do the trick. Here's the links to the functions: [url]http://www.cplusplus.com/reference/clibrary/cctype/tolower.html[/url] [url]http://www.cplusplus.com/reference/string/string/replace.html[/url] Also, line 12 should give you an … | |
hello, I'm working on a personal project and I was looking for some help. I am writing a program that needs to store user profiles in an external file (.user_data.dat). Problem is that anyone with half a brain can find the file and with any text editor look at the … | |
hey, been working on a program and I had a need for a password line (btw I am using linux w/ gcc compiler). while I was making it I checked the net and found there's no getch() for linux, so I frankensteined one from several sources and got it to … | |
Re: ok, I have a hard time believing that this is the first program required of you, but whatever. Starting with the first one, you'll need to research classes and member functions. The basics of which would be the following in your case: [CODE] class Calculator { //class attributes and such … | |
hi, this should be a fairly simple question to answer. I have a function in my program that takes the content of a text file and populates an array with all the information. First it has to see how many lines the file has (as it can change) so it … | |
hello, I'm relatively new to C++ (but not to programming) so I wasn't sure how to do this in C++. My brother wrote a bash script which is used primarily to transfer files between computers using rsync which he asked me to convert to C++ so that it can be … | |
Re: (seeing as I can't delete a post, to prevent redundancy, I'll give an alternate solution) Hi, in the case of setprecision() not working, try the following: cout.setf(ios::fixed); // prevents e-notation cout.setf(ios::showpoint); //always shows decimal point cout.precision(2); // with 2 being the number of decimals using that, here's what happened in … | |
Re: Hey, looking at your program looks like you have a few simple errors, logic and otherwise. #include "stdafx.h" #include <iostream> using std::cout; using std::cin; using std::endl; int main() { int n; cout << "Please enter a integer "; cin >> n; for (int i = n; i <= 25; n++) … |
The End.