15,300 Posted Topics
Re: When you enter an integer the program leaves the <Enter> key '\n' in the keyboard buffer so the next getline() will just extract it instead of waiting for more keyboard input. You need to flush that '\n' out of the keyboard buffer after the [icode]cin >> age[i];[/icode] One way to … | |
Re: you could use pipes. see man pages for popen() | |
Re: You don't need those loops in readb() and writeb(). All it takes is one line of code, using fread() and fwrite(). | |
Re: The parameter to open() has to be a null-terminated character array (commonly called a string). All you are trying to send it is a single character. Try this: [code] [color=red]int[/color] main() { int i; char* letras[3] = {"a","b","c"}; for(i=0;i<3;i++) { ofstream print(letras[i]); } } [/code] | |
Re: line 48: it is not reading the value of [b]n[/b] from the data file. You need to put [icode]f >> n;[/icode] between lines 47 and 48. delete line 49 because that's the default when files are opened for reading. line 50 should be this: [icode]file.read((char*)B,sizeof(books));[/icode]. The value of [b]i[/b] is … | |
Re: Illegal software, so its just as well you can't use it on Windows 7. SNIP | |
Re: didn't your instructor tell you where that IC number comes from? AFAIK there is no online database of IC numbers. | |
Re: we don't do homework for you, but we will help you if you have specific questions. Post what you have tried. | |
Re: You need to try to do that yourself. We are not here to do your homework for you. If you don't know how to do it then just read your text book that you bought when you signed up for that course. | |
Re: Read the file one word at a time, instead of one charcter at a time. If the word contains digits then convert the entire word to int so that "10" becomed 10. line 10 should be an array of ints, not an array of char, so that it can contain … | |
Re: you will need to declare an array of ints that hold the individual test scores so that they can be averaged later. Then pass that array to the function to computes the average. Declare and allocate the array between lines 11 and 12 of the code you posted. [icode]int* arry … | |
Re: Your description of the problem is somewhat unclear. What does "and as how many times user" mean? >>i have written some code, please see it and correct it : What is wrong with it? Are you getting compiler errors? If yes, then what errors? And what compiler? | |
Re: Here is one way to do it [code] #include <string> #include <sstream> using namespace std; int main() { string s = "Adder: 4, yes"; stringstream str(s); string m; int n; bool b; str >> m; // "Adder:" str >> n; // 4 str >> m >> m; // extract comma … | |
Re: If you want to do it as a function then pass the string by reference [code] void addDoubleQuotes(std::string& str) { str = '\"' + str + '\"'; } [/code] | |
Re: I don't see anything wrong with it -- but did you post exactly the same thing that is in your program? Maybe you need to post more of the program. | |
Re: lines 12 and 13. You can not allocate or delete those arrays yourself. If you want to clear out the values then just set them all to 0. memset() is the quickest way to do it, but there are other ways too. [icode]memset(series_number, 0, sizeof(series_number));[/icode] And before anybody complains, yes … | |
Re: 1) First off I assume you are an American because that's American currency you have to deal with. If not, then you might have a problem. 2) Second, I assume you know how to make change. If you owe me 25 cents and give me a 10.00 bill, how much … | |
Re: [QUOTE=CaptainMack;262238] Well the homework i have been given was to design and make a program that would convert binary code into a denary integer also backwards from denary to binary code. I have done a bit of research through the internet, and i have seen some simple programs just by … | |
Re: Well, what is the expected output? I can't read minds. | |
Re: I made a couple attempts to install Office 97 on 64-bit Windows 7, and the both failed because some of the DLLs could not be registered. After installing the basic Office 97 from CD, I tried to install SP1, and it failed due to DLL registration problems. So I tried … | |
Re: >>However the array dosent show What does that mean? And please use code tags. | |
Re: Of course there is. Just use the stream's >> operator [code] int n; ifstream in("filename.txt"); in >> n; [/code] | |
Re: line 9, my_vector.h [color=red]NEVER EVER[/color] include a *.cpp file in a header file. It doesn't work. You didn't say what compiler you are using but you have to compile all *.cpp files and then link the object files together to make a single executable program. | |
Re: It doesn't work on modern MS-Windows operating system. Those escept codes are intended for Win95 and MS-DOS Version 6.X and earlier which had ansi.sys device driver installed. ansi.sys has not been in use since probably Windows NT 4.0. [URL="http://support.microsoft.com/kb/101875"]See this [/URL]Microsoft article. | |
Re: c++ does have standard libraries and a whole set of standard header files. There are at least a hundred or so of them. Look in your c++ compiler's installation directory and you will find the libraries stored in the lib directory and header files in the include directory. The directory … | |
Re: >>so it's potentially got multiple leading zeroes, which will be lost in the conversion process from int to string to int. What's the problem with that? Integers never contain leading zeros, whether the strings have them or not. What I would do is convert the three integers into seconds so … | |
Re: My bet is that the window is closing before you have a chance to see the output. The reason is that when you enter numeric data the program will leave the Enter key '\n' in the keyboard buffer, and when cin.get() is called it just retrieves it. When you need … | |
Re: Bips: how did you ever get the silly idea that you can run a program written 20+ years ago for MS-DOS on a *nix box?? | |
Re: how would you connect to what? How do you compile it? You have to use a compiler. Two free ones are Code::Blocks and VC++ 2008 Express. | |
Re: >> If I compile a simple Hello World! program on a 64bit linux, will it work on a 32bit linux? Depends on the flags you give the compiler. The default is to produce 32-bit code, but you can tell it to produce 64-bit code. Just because you are running a … | |
Re: You need to clearly define terms, such as "sentence", "atomic sentence", "conjunction", etc. Don't just assume we know what those terms mean. | |
Re: Forget Vista and upgrade to Windows 7. But you will have to do a clean install, not an upgrade. Backup all files you want to save before starting because Windows 7 installation will reformat the hard drive. But if you insist you must upgrade to Vista, just put the Vista … | |
Re: Your program doesn't have to open the file, the operating system redirects the file contents to stdin of your program, just as if you are typing the data from the keyboard. Get your program working while typing the data on your keyboard, then when that works ok just run it … | |
Re: line 83 is wrong [code] void removeElement(std::vector<std::vector<std::string> > &Mat, std::string El) { [color=red] std::vector<std::vector<std::string> >::iterator [/color] ITx = Mat.begin(); for(; ITx<Mat.end(); ++ITx) { std::vector<std::string>::iterator ITy = ITx->begin(); for(; ITy<ITx->end(); ++ITy) { if(*ITy == El) { ITx->erase(ITy); } } } } [/code] | |
Re: The 2d linked lists I have worked with in the past is really nothing more than a linked list within a linked list. Something like this: I have not done it using templates. [code] struct node { struct node* next; void* data; struct node* head; // head of another linked … | |
Re: switch() is just swapping the variable addresses (which are local to switch funcction), instead of the values stored at those addresses [code] void switch(int* x, int* y) { int hold = *x; *x = *y; *y = hold; } [/code] | |
Re: right click the IE icon in the task bar, then from the popup menu select "Internet Explorer", near the bottom of the list. | |
Re: You can do this [code] class test { public: std::string write(); }; std::string test::write() { std::string name = "HELLO"; return name; } int main () { test A; cout << A.write() << endl; return 0; } [/code] | |
Re: This has to be one of the dumbest polls I have seen in my four years here at DaniWeb. | |
I installed Windows 7 this morning, then installed VC++ 2008 Express again. Now I want to install a dependency walker in its installation folder. But suprise suprise, the folder is marked read-only. Using Windows Explorer to change permissions does nothing. Yes, my account is set up as Administrator (already checked … | |
Re: 1) Are you compiling for UNICODE? 2) what compiler 3) how is UPDATE_DIR declared 4) note that %s and %S are not the same thing. [URL="http://msdn.microsoft.com/en-us/library/hf4y5e3w%28VS.80%29.aspx"]See this[/URL] | |
Re: Better still, uninstall that IDE/compiler and use Code::Blocks with current version of MinGW compiler. | |
Re: >>if (the number is a character) //don't quit get that You will need to get the number in a char variable, not an int variable. Then the above line will make sense because you need [icode]if( !isdigit(character)) [/icode] maybe this will make more sense [code] #include <iostream> using namespace std; … | |
Re: What problem are you having? You need to post the code you have tried. If you have not started yet, why not? Do the program in small steps -- do the first part first. When that is finished and tested, then move on to the second part. | |
Re: >> while( k != isalpha(ch) || k != MAX_DIGITS) The problem is that line. Why test for k != isalpha(ch) ? The loop counter has nothing to do with the value of ch. And if you type fewer than MAX_DIGITS then the next cin.get() will wait for you to enter … | |
Re: MS-Windows: Sleep(int milliseconds) *nix: sleep(int seconds) There is another one too that takes milliseconds but I don't recall its name. In MS-Windows you can call WiatForMultipleObjects() to put the main thread to sleep until all worker threads have finished. You don't need that loop at all. | |
Re: When using random numbers there is no guarentee you will get 5 heads and 5 tails. | |
Re: If you only enter one argument then argv[2] is invalid. The program will only have argv[0] and argv[1]. | |
[URL="http://www.stumbleupon.com/s/#2aDeft/ellen.warnerbros.com/2009/10/big-ash-twitter-1023.php/"]Got this link [/URL]from twitter -- theEllenShow | |
Re: Just use a linked list of stacks. Are you using a structure to represent the stacks? |
The End.