- Strength to Increase Rep
- +15
- Strength to Decrease Rep
- -3
- Upvotes Received
- 286
- Posts with Upvotes
- 252
- Upvoting Members
- 160
- Downvotes Received
- 39
- Posts with Downvotes
- 34
- Downvoting Members
- 21
1,494 Posted Topics
Re: The difference between a democracy and a dictatorship is that in a democracy you vote first and take orders later; in a dictatorship you don't have to waste your time voting. Charles Bukowski | |
Re: You have some fundamental problems with your code especially the lack of a proper formating scheme..Also please use code tags. [code] #include <iostream> using namespace std; int main() { int num; cout << "Enter a two-digit number:\n"; cin >> num; int ones_digit = num%10;//preform these operations int tens_digit = num/10;//after … | |
Re: Here's a quick example of a parent receiving from a child which receives from a child...It should be 'mostly' correct. [CODE] #include <stdio.h> #include <stdlib.h> #include <unistd.h> enum PIPES {READ, WRITE}; int main(int argc, char**argv) { int hpipe[2]; pipe(hpipe); if (fork()) { /*parent*/ char ch; close(hpipe[WRITE]); dup2(hpipe[READ], 0); close(hpipe[READ]); while … | |
Re: Really, why would you want to? You know that some of the binary characters have no ascii representation, hence can't be displayed. It would be better to display each binary value in hex, thus displaying each and everyone of them. | |
Re: Instead of starting at zero and incrementing try starting at columns value and decrementing to zero.. | |
Re: Measuring execution time is a very complex task...just check the link titled [pdf]Measuring Program Execution Time [url]http://www.google.ca/#hl=en&source=hp&q=linux+execution+time&btnG=Google+Search&meta=&aq=1&oq=linux+execu&fp=7e102d89cbdc458f[/url] | |
Re: Has anyone checked the date of this posting...Apr 6th, 2007 | |
Re: [CODE] #include <iostream> unsigned int addone(unsigned int x) { unsigned int y = 0; unsigned int z = 0; for (int i = 0; i <= 31; ++i) { z = (x<<(31 - i))>>31<<(i); if (z > 0) { x = x ^ z; } else { y = x|0xffffffff; … | |
Re: In my very limited view of C++, I find Accelerated C++ and Ruminations on C++ very beneficial to the newest C++'ers. Its such a great introduction to the understanding of the principles of the language. Thank-you Andrew Koenig and Barbara Moo..I appreciated yours words of wisdom. | |
Re: For starters, you might want to move this above the main() function like: [CODE] void swap(int *, int *); //prototype with a pointer parameter int main() { ... } [/CODE] | |
Re: Try creating a pipe. Here's a simple example. [code] #include <iostream> #include <unistd.h> enum PIPES {READ, WRITE}; int main(int argc, char**argv) { int hpipe[2]; pipe (hpipe); if (fork()) { close (hpipe[WRITE]); int x = 0; while (true) { read (hpipe[READ], (char*)&x, sizeof(int)); if (x < 0) break; std::cout<<"child recieved->"<<x<<"\n"; } … | |
I have a simple question about unicode and utf8. How does a utf8 encoding know what its uppercase encoding is? I understand how utf8 encoding carries its unicode value embedded in itself but I fail to see how it maps a utf8 encoding to an uppercase unicode value. What is … | |
Re: It would probably help if you disclosed which Windows and what error.. | |
Re: Line 27 should be: [code] c.str[m]=' '; [/code] Line 29 should be: [code] for(int len=m+1;(*b.str)!='\0';len++) [/code] This is how I would solve it: [code] class string { public: char& operator[](int offset); const char& operator[](int offset) const; friend string operator+(const string & lhs, const string & rhs); }; const char& string::operator[](int … | |
Re: Sure just type firefox [url]www.google.com[/url] | |
Re: How can i do it? Depends. Do you want to overwrite the characters or do you want to insert the characters and shift everything down.. | |
Re: [QUOTE=Rallici;1465475]I aint ganna lie. I have no clue how to attempt this I have read about it online but every time i attempt to i fail miserably.[/QUOTE] I would delete the compiler/IDE and then reinstall it. | |
Re: Try something like below: [CODE] #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char inputstr[128]; char *cptr = &inputstr[0]; size_t thesize = 128; while(1) { if(feof(stdin) != 0) { break; } getline(&cptr, &thesize, stdin); printf("input string is : %s\n", inputstr); } getc(stdin); return 0; } [/CODE] | |
Re: Or posting in the wrong section? | |
Re: I think you are confused. First you write the program and then you post it with any problems you are having. | |
Re: Ok, which functions and line numbers are you talking about? | |
Re: The solution or hints of a solution depend on which data structures you plan to use. Could you post what you have so far? | |
Re: I have a question about this line scanf("%d", &val); Why are you reading a integer into a character? Won't it make more sense to read the characters directly into the character array? scanf("%20s", a); | |
Re: Shouldn't this scanf("%s", &employeeIDNew); be scanf("%s", employeeIDNew); | |
Re: Well 3 divided by 5 has 3 left over. The modulus operator computes the remainder of integer division. | |
Re: I guess you are not aware of our homework policy. We don't do homework problems. If you want help with a specific problem then you'll have to post the code and indicate exactly where and what the problem is. | |
Re: You can set the delimiter for getline(). istream& getline (istream& is, string& str, char delim); Please check out this link http://www.cplusplus.com/reference/string/string/getline/ | |
Re: You seem to be missing the opening brace here void toss(int & x)//missing brace here //0=heads 1=tails x=rand()%2; | |
Re: OK. What have you tried so far? | |
Re: I think you can use any compiler which has the ability modify the linker, GNU's compiler has linker scripts which controls this important aspect. | |
Re: Try running this program with your data. #include <iostream> #include <fstream> using namespace std; int main(int argc, char** argv) { ifstream names; names.open("P25.txt"); string data; while(names >> data) { cout << "You read->" << data << "<-into data!" << std::endl; } names.close(); return 0; } | |
Re: Could you please give more details? | |
Re: C++ is a play on the C programming language increment operator. C++ literally means C language incremented. What's the purpose of it? Here check the wiki http://en.wikipedia.org/?title=C%2B%2B | |
Re: Are you sure your compiling this with a C++ compiler? Could you be using a C compiler? | |
Re: Well this is how you access an element of std[100] and get its elements. std[searchid].id std[searchid].name std[searchid].fatherName std[searchid].motherName | |
Re: Try reopening the input file or setting the file position back to the beginning with fseek() on line 22. | |
Re: The GCC compiler has a switch -std which can determine the language standard. Try searching this link for the -std switch options. http://linux.die.net/man/1/gcc ![]() | |
Re: Shouldn't this have a semi-colon after it? struct item { int* num ; int* q; };//semi-colon Why are the structure elements pointers? If you insist on pointers then you'll have to allocate memory for them or point them to valid memory before you use them. ![]() | |
I'm curious as to where a member would post a question on ML(Ocaml) type language? | |
Re: If you insists on breaking out of the loop immediately then you should use break. Something like this... #include <iostream> #include <iomanip> using namespace std; int main() { int employeeNumber = 0; while( true ) { cout << "\nEmplyee Number: "; cin >> employeeNumber; cout << endl; if ( employeeNumber … | |
Re: Could you elaborate on your question? | |
Re: Well what do you need help with? Please post the code you attempted and highlight any sections and explain the problems. | |
Re: If you want to save yourself some frustration then don't include this in your header file using namespace std; Header files shouldn't expose anything in a namespace. | |
Re: Did you try the function tolower()? You could apply this to each character and perform any calculations to the result. | |
Re: This forums provides help to users who have specific questions. It isn't a free programming advice column. | |
Re: I would have to say that you need a flagging system which marks a integer element when its been counted. Are you sure this is C? for(int i = 0; i < 10; i++) { ... } | |
Re: The arrays are fine! Do you have another problem with the code? Doesn't this for loop run past your arrays? for (int d = 0; d < 10; d++)//arrays have five elements { ... } This function returns int but you return boolean inside the function. What does this function … | |
Re: Looking at your code I find that you have to make a decision. Do you want to calculate the average once and store the value in the structure Student or do you want to calculate the student average each time you need it. void Print_List(Student List[], int Size) { cout … | |
Re: Number one. Why all the semi-colons? Here. Can you spot the error now? class Timerange { public: Timerange(string initstring) { string current = ""; unsigned short mode = 0; string timeA; string weekday; string timeB; for(unsigned short i = 0; i<initstring.length(); i++) { char c = initstring[i]; if (c == … |
The End.