15,300 Posted Topics
Re: [quote] for (int d=0;d< fn.length();d++) file_num[d]=fn[d]; [/quote] Why not just use the assignment operator ? No need for that loop [icode]file_num = fn;[/icode] >>string file_name=loction+file_num+extention; That is a little odd. Why not use the fd parameter and delete the loop quoted above ? [icode]string file_name=loction+[color=red]fn[/color]+extention;[/icode] >>ofstream ofile ("file_name", ios::out); Remove … | |
Re: post the code you have written. Start very simply and do the requirements one at a time. Step 1: For example, [b]"Write a c++ program"[/b]. Well, here it is [code] int main() { // code goes here } [/code] Step 2: Next you need to create an int array that … | |
Re: One way to do that is to create an integer to contain the sum of each group. [code] int sum1 = 0; // 0-20 int sum2 = 0; // 21-40 // etc for each group [/code] Then while reading each value from the file compare it with the gruping [code] … | |
Re: line 57 main.cpp: g.calcAvgHandi(handi, count); handi is an int, not an array. Similar problems with the other lines. | |
Re: Your program is experiencing out-of-bounds errors. The arrays are allocated 17 elements numbered 0-16 and your program is attempting to write to elements 1-17. Element #17 does not exist. Learn to count the C and C++ way -- with 0 as the base value. Your program is chuck full of … | |
Re: Why don't you use c++ strings and vectors instead of re-inventing the wheel [code] #include <string> #include <vector> using std::string; using std::vector; // other using statements here class str_pair { public: str_pair() { counter = 0; } str_pair(string ip, string uri) { this->uri = uri; this->ip = ip; counter = … | |
Re: The or operator is combining those items. For example lets assume #deifne CS_DBLCLKS 0x01 #define CS_OWNDC 0x02 #define CS_HRDRAW 0x04 So when they are or'ed you get 0x01 + 0x02 + 0x04 = 0x07 [URL="http://www.winprog.org/tutorial/"]Here [/URL]is a good beginning tutorial in win32 api programming. | |
Re: If you would erase() the element instead of replacing it with an empty string you wouldn't have the problem you are posting. | |
Re: log files are just simple text files. I usually put the date/time at the beginning of the log entry. I wouldn't bother with any of the MFC file functions such as CFile and CArchive. Use normal fstream objects. The log function should open the log file, write the log entry … | |
Re: you mean this? [icode]if( list.students[n].id == student)[/icode] | |
Re: I don't understand how sending something thru a comm port is going to generate a timer interrupt ? If you have the source code maybe you can just recompile it with a more modern fortran compiler, such as [URL="http://www.geocities.com/athens/olympus/5564/"]this one.[/URL] | |
Re: after using cin call peek() to see if the next character is '\n' or not. [code] int x; cin >> x; if( cin.peek() != '\n') cout << "Bad\n"; [/code] Or get it as a string and check each character. | |
Re: Don't do it like that because it would cause a huge security risk. Instead, have the client pull the file from the server, run it and send results back to server. >>Plz give me hint or any sample code??? Client/server sample code ? You can find some at [URL="Plz give … | |
Re: If you want to be able to scroll backwards in the file then you need to keep track of the beginning of each line. call ftell() to get the current byte location, then after reading the next line just call seek() with the location that was returned by ftell(). If … | |
Re: >>strcat(screenReturnValue,screenClassName.c_str()); You are attemtping to copy screenClassName into some unallocated memory pointer. [b]screenReturnValue[/b] must be allocated before executing this line, and it must be allocated enough memory to hold both screenClassName and "Ptr". To fix it, use the [b]new[/b] function to allocate the memory [icode] char* screenReturnValue = new char[screenClassName.size() … | |
Re: Pass the open stream to each function as a parameter. [code] void func1(ifstream& in) { } void func2(ifstream& in) { } int main() { ifstream in("myfile.txt"); funct1(in); funct2(in); } [/code] | |
Re: what part of findMe () don't you know how to code ? Look at this line and you will see what parameters it needs to have. All parameters should be passed by reference. [icode]if (findMe(lookmeup, names, score, tmpscore))[/icode] | |
Re: >>while (firstName != 0) You can't test std::string objects like that [icode]while(firstName != "")[/icode] might work for you here. | |
Re: your coding style is terrible. Don't be afraid to use more white space -- it won't slow down the compile time any and won't take up any more room on your hard drive. | |
Re: Narue: I liked the other one better That lady holding the chainsaw and wearing Jason's mask just did something for you. :) | |
Re: welcome to DaniWeb Chess. Hope you can help out around the Tech Talk boards. | |
Re: line 65: That's a do nothing line, so you might as well delete it. you need 8 ranges so create an int array with 8 elements so that array[0] represents the quantity of numbers within the first range, array[1] is the quantity of numbers in the second range, etc. etc. … | |
Re: [URL="http://www.1728.com/loanform.htm"]Here[/URL] is the formula for calculating the monthly payment [code] int main(){ float loanAmt; float interestRate; int Months; float MonthlyPayment; cout << "Enter load amount ..."; cin >> loanAmt; cout << "Enter interest rate (e.g. 6.5) ..."; cin >> interestRate; cout << "Enter number of months ..."; cin >> Months; … | |
Re: I think that you need is this: The comments I made are things you need to do to complete the assignment. [code] const int size = 10; // or whatever number you want int number[size] = {0}; // initialize all elements to 0 int key_value = 0; // initialize all … | |
Re: The first number indicate the minimum width of the field, for example "%2d" will print a number at least two characters wide. If the actual number is only one digit the first character will be a space. If the actual number is more than 2 digits the program will display … | |
Re: I've always read that you should never put code in a constructor that might cause an exception. For example if you need to allocate memory in the contructor then put it in an Initialize() method where the exception can be safely caught and/or thrown. | |
![]() | Re: >>My problem is with kbhit(), is there no way of resetting it, so that I can reuse it? Yes, extract the character from the keyboard [code] if( kbdhit() ) getche(); // or some other function that extracts the key [/code] >>The restrictions though was that I should use "standard" libraries … ![]() |
![]() | Re: At the end of getData() you need to add code to remove the '\n' from the keyboard buffer. Getting numbers (ints, floats, doubles) has the side affect of cin leaving the Enter key '\n' in the keyboard buffer, so the next time a character string needs to be entered cin … ![]() |
Re: The parameter [b]filename[/b] is going to contain all the bitmap data? :icon_eek: Then where is the name of the file that function is supposed to write it to ? I'd say you need to redesign the parameter(s) to that function because that is just screwy. | |
Re: The next step is to write the implementation c++ code for each of the methods you have in that class. Here's a start: [code] #include "hills.h" // or whatever you named the file you posted // constructor LinkedList::LinkedList() { // initialize the class variables head = 0; tail = 0; … | |
| |
Re: move all the code that is in main into a different function -- just rename main() to something else. Then create a new main() what has a loop that calls that function [code] int some_function() { // blabla return < 0 to end program, or non-0 to continue > } … | |
Re: ban rap music ? No, just clean it up, and it should be the music industry, not the government, that does it. Afterall TV stations wouldn't show Elvis below the waste either because of his lewd shaking of the legs :) In 20 or so years from now today's rap … | |
Re: >>This could lead in deep discussion about who is made a first gunpowder No deep thought needed to answer that --[URL="http://www.enotes.com/science-fact-finder/general-science-technology/when-where-was-gunpowder-invented"] the Chinese invented gunpower.[/URL] | |
Re: Welcome to DaniWeb. Glad to see that another retired person is here. If you put those classes into a <vector> then you can use std::sort to sort them. All you have to do is write a set of functions that will be called by sort() to return true or false. … | |
Re: I think it would be a lot easier to move the node's data around instead of trying to move the nodes themselves. Moving the nodes means you have to correct all the links. You don't have to do that if you just move the data. | |
Re: [URL="http://www.daniweb.com/forums/thread90228.html"]Here is a suggestion [/URL]how to flush the input stream. | |
Re: start [URL="http://msdn2.microsoft.com/en-au/isv/bb190538.aspx"]here[/URL] | |
Re: >>&theMessage That make it a pointer to a pointer. You don't need the & symbol because theMessage is already a pointer [icode]memcpy(&myStruct, theMessage, sizeof(theMessage)); [/icode] | |
Re: zip the project up and attach it to a post. Don't include any object files or other files that are generated by the compiler. And it would be nice to know what operating system and compiler you tried to compile/link with. | |
Re: >>If someone could possibly do the exercise and run my through it, i would be really grateful. I'm sure you would be gradeful. I'll be grateful too if you deposite $10,000.00 USD in my PayPal account. After you do that then I'll gladly email you the program. | |
Re: Anyone have a crystle ball I can borrow? I lost mine somewhere. Also, that seems to be a C program, not c++. | |
Re: add this to the top of your program [code] #include <iostream> using namespace std; [/code] | |
Re: Its a lot simplier in c++ [code] ifstream in("myfile"); int n; in >> n; [/code] | |
Re: [URL="http://students.cs.byu.edu/~cs460ta/cs460/labs/sockettutorial.html"]socket tutorial[/URL] and another one [URL="http://www.uwo.ca/its/doc/courses/notes/socket/"]here[/URL] No matter what you do there is some basic amount of socket programming you will have to do. | |
Re: >>what makes these two functions better to use over execl and execv? Nothing. It just depends on how you want to use them. As described [URL="http://linux.die.net/man/3/execlp"]here[/URL] execlp will search the PATH environment variable for the executable if [b]path[/b] parameter does not contain a slash. | |
Re: you can get it with the Microsoft Platform SDK free from Microsoft. | |
Re: try fgets() [code] char menuchoice[2]; printf("please enter:"); fgets(menushoice, sizeof(menuchoice), stdin); return menuchoice[0]; [/code] |
The End.