181 Posted Topics
Re: Do some research on the getline() function. It is in the iostream library. It has an overloaded form that accepts a third argument which is the delimiting character. | |
Re: I'm not really sure what your trying to accomplish here. Your for loop is incorrect because what if the file doesn't contain 81 characters? What if the file has a string with more than 81 characters? When checking for an EOF, consider looping through with a while statement like [CODE=c++]while(!inFile.eof())[/CODE]. … | |
Hi All, I am writing an MFC Tic Tac Toe app and I am getting a strange error when debugging it. This module loads a bunch of BOOL variables to keep track of whether or not the tile next to it matches (i.e is the tile next to me also … | |
Re: cipherText was not declared in main(). When I compiled this I had to add [CODE=c++]string cipherText;[/CODE] to main(). Your encryption and decryption functions are going to need some work because saying something like cipherText[i] - key is not going to remove the int from the end of the string (If … | |
Re: When you say "only seems to run once then does nothing." do you mean the program hangs or crashes or it only goes through one iteration and then exits? | |
Re: Something simple like this?? [CODE=c++]const int SIZE = 10 // Or whatever size you want the array to be int array[SIZE]; ofstream oFile("c:\\someDirectory"); // Load Array for (int i = 0; i < SIZE; i++) array[i] = i; // Output to file for (i = 0; i < SIZE; i++) … | |
Re: You need to make the lList class inherit from the Node class if you want to access the protected members in Node from lList. [CODE=c++]class lList : public Node { // Insert code for class } [/CODE] | |
Re: One way of doing it would be to use a 2 dimensional array of strings. For example: [CODE=c++] // Array that will hold 10 different lyrics, up to 20 words per set string lyrics[10][20]; [/CODE] Now say that song number 4 is chosen and you want to randomize which word … | |
Re: Well first, you are going to want to modify your add_record function. It is better practice to do most of your cout's and cin's in main (or in this case you can also do them in menu() ) and pass the arguments to the function to add them to the … | |
Re: In the parameter list for your function prototypes and definition you need to declare the parameter as accepting an array of that struct type. Example: [CODE=c++]void showMenu(airplane arr[], int numberOfTickets); [/CODE] When passing arguments to that function, only pass the name of the instance of your airplane struct. Example: [CODE=c++]showMenu(tickets, … | |
Re: You cant get the file to open? Does the file exist in your project directory? Also, in lines 37 and 38 you do: [CODE=c++]if (i % 2 == 0) evenSum += i; if (i % 2 > 0) oddSum += i;[/CODE] You have never initialized i with a value. This … | |
Re: Unless you have to constantly read/write from the file as a requirement for the project, I wouldn't do that. I would load all the data (Since these files are not large) into a data structure of your choice (Anything from a simple array of structures to a linked list, binary … | |
Re: The other possibility is that the prof wants one object to hold the data about the rectangle and another object that can perform operations on it. EX. [CODE=c++]class Rect { double len, wid; public: Rect(double l, double w) : len(l), wid(w) {} double getW() {return wid;} double getL() {return len;} … | |
Re: Explaining how file streams work in detail is not going to be something that anybody here really wants to do. What you should do is study up on file IO (Using your book, interwebs etc.), write some test code and post it with any questions/ problems. | |
Re: Could you post the code? Have you done any debugging? | |
Re: Whats the compiler error that your getting? | |
Re: [QUOTE]My question was more like, how does Windows work?[/QUOTE] WTF?? This question is going to take a lot longer to answer than you think lol [QUOTE]The intent behind my program is to replace all the functionality of the mouse with key presses. It will not have a graphical component. It … | |
Re: Keep in mind that different compilers may not interpret your code the same way. You may have to modify it. Can you post the code that you have? | |
Re: Keep in mind that windows Vista and 7 have much more memory read/ write protection than XP did. Try right clicking on your executable file in Vista/ 7 and choosing 'Run as Administrator'. | |
Re: I have a feeling this "skeleton code" was the code given to you by the teacher. This isn't a finish your homework for you club. | |
Re: Yea your approach is definitely a little off so far. Do you want your program to count how many times a letter (that you specify) appears in a certain string? For example: How many times does the character 'p' appear in the string "apples"? And you want your class to … | |
Re: Just by looking at the questions you are asking, I can tell you are not ready for this type of programming. | |
Hi All, I have been programming for a while, currently a junior CS student. Programming has always felt very natural to me and I pick up new concepts quickly and I generally retain most of what I learn. However, when it comes to converting between Dec/Bin/Hex as well as performing … ![]() | |
Re: [CODE=c++]name = new char[n];[/CODE] You are allocating memory for a new char array but you are using a variable with data type char for the size declaration. n is a char type and should not be used to declare the size of the array and it is never initialized or … | |
Re: Welcome to the forums. I recommend reading the forums rules because you will see that people will not help you with these kinds of questions. You need to first learn the basics of what to do (Read books, classes, etc...), post your code, then if you have problems people here … | |
Re: The structure of you program overall is a little off. The option to Quit should really only be contained in the main program loop. So you should present all of the options that the program can do (which includes quit) just in the main menu. | |
Re: [QUOTE=Codname47;1270271]node &getNode(int index) { //NOT TESTED if (index <= getLength() || index >= 1){ temp = new node; temp = head; for (int i=index-1; i>0; i--){ temp = temp->next; } return &temp; } } Hi everyone, I receive this error msg: "invalid initialization of non-const reference of type 'node&' from … | |
Re: Well that sounds like fun...... Why don't you start by posting code that you have already written so we can take a look at it. Nobody here is going to do the work for you | |
Re: [QUOTE=pinsickle;1210672]I have always done something like this [CODE]if (!myfile) { // error message // exit (1) } // do file stuff here [/CODE][/QUOTE] I usually do this as well..... however you can use the fail method which is contained in the newer fstream lib [CODE=c++] ifstream someFile("whatever.txt"); if (someFile.fail()) { … | |
Re: Ok so first off.... code tags. And second.... what the heck is this?? [CODE] if string openfile(" image.bmp") [/CODE] | |
Re: [QUOTE=niek_e;1107865]Try reading the rest of the replies in this thread and then figure out why you're not going to get it.[/QUOTE] Lol... some ppl never learn | |
Re: You just want to dynamically allocate a new array of your struct right? Like this: [CODE=c++] myStruct* mySimpleClass::myFunc1 (int arraySize) { myStruct struct1 = new myStruct[arraySize]; return struct1; } [/CODE] | |
Re: I agree with matt, HKEY_CURRENT_USER is just a const value or enumerated type, so you would need something like a switch case statement to cout the textual representations | |
Re: What about calling the generateString function within your buttonclick function, except have generateString return the string instead of void [CODE=c++] private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { String^ getgenerateString = generateString(); } String^ generateString() { String^ sendThisString = "SendThis"; return sendThisString; } [/CODE] | |
Re: Well the problem with that is once a .DLL is compiled you can't edit it directly, you need the C or CPP source file(s) used to create that DLL, then you edit those | |
Re: I agree with jwentwing.... we are not a homework service | |
Re: People on here are not going to respond to your post, it is junk. Why? Well first please read the posting rules (that will pretty much tell you why) You can't just say heres my program, what do I do to finish it? You need to put in the effort, … | |
Re: I have gotten the Side by Side config problem before. I made a simple program to modify the Windows XP registry Hive files using the Win32 API and it worked fine on my laptop (The comp that I created it on) However on some computers and in a PE enviroment … | |
Re: Its kind of hard to help because I don't know what your input files look like but I noticed two things. Lines 21 and 80 are [CODE=c++]while (source.fail())[/CODE] Those should be if statements because it will continuously loop if the file open process fails. Also, have you put a couple … | |
| |
Quick question. I have a program that will run perfectly fine in the Debug version (Using MS VS 6) but when I set it to Release and build it, then set the command line arguments (or run it from the comman line) it blows up. Any ideas why this would … | |
Re: We help users based on specific question, not "Can you do this for me?" Start with a UML diagram to model ure class and go from there. If you get stuck at a specific point, post the code | |
Re: Provided I have no code to look at, if your programming in windows you need two "\" in the filename if you are defining the path explicitly. However, the way you are doing it you only need to type one backslash. Have you tried outputting szFileName to see what it … | |
Re: Also in line 30 you have [CODE] for (int k = 1; k = 0; k++) [/CODE] the problem is that you are not testing for anything, you are reassigning k to 0 because you are using the single equals | |
Re: Dude, you've already been told about code tags and where to use them, AND where to find info about them on the forum. I cant help you if I cant read your code... i.e the messy brackets in your nested loops because of the lack of code tagging | |
Ok, having some serious trouble here. My proffesor told us to write a progrm (what it does really doesnt matter here) however he wants a FULL color menu in the console. He showed us an example of what he wants, it was very cool, it had a red backround, then … | |
Re: normally we try to help people here an not do the work for them but yea.... ok | |
Re: [QUOTE=geoldr;1126202]That's what I am trying to do but am not exactly sure how to get my file contents into an array.[/QUOTE] Well there are a bajillion ways to do that but.... a quick dirty way: [CODE=c++] fstream iFile("myFile.txt", ios::in | ios::beg); const int MAX = 15; string words[MAX]; int index … | |
Re: i Know ure new to posting here so... please read the "Before you Post" guides in the forum list. USE CODE TAGS! |
The End.