200 Posted Topics

Member Avatar for vikuseth

A static class member exists on a class level as opposed to non-static class members that exist on an object level. For example, what you can do with s_b but not with b is access it without having an "A" object, as it's not part of an object but of …

Member Avatar for deceptikon
0
181
Member Avatar for pestallozi

Example of b #include <stdio.h> int Highest (const int l, const int r) { return ((l > r) ? l : r); } int Lowest (const int l, const int r) { return ((l < r) ? l : r); } void FindMinMax (const int A[], const int n, int* …

Member Avatar for pestallozi
0
121
Member Avatar for Ranjan_1
Member Avatar for artur.sinelnikovs

Depends on how you want it to work. If you expect the formula as a single string you could do something like: #include <stdio.h> #include <string.h> #include <stdlib.h> int main(int argc, char *argv[]) { int num1, num2, result; char op; int check=0; if (argc != 2) { printf("usage: %s <formula>", …

Member Avatar for deceptikon
0
163
Member Avatar for MrBoye

Muh. first, askk for the initial balance of the bank accounts So what have you tried, and what isn't working as expected? If you haven't gotten to the point of coding yet, what part of the design is it you cannot develop? reject negative balance So what have you tried, …

Member Avatar for Lucaci Andrew
0
266
Member Avatar for neewb

You could "outsource" validation. If your regex is working, you could use [match_results](http://www.cplusplus.com/reference/regex/match_results/) to obtain the different section, create a [tim structure](http://www.cplusplus.com/reference/ctime/tm/) and pass that to [mktime()](http://www.cplusplus.com/reference/ctime/mktime/) for validation.

Member Avatar for Gonbe
0
244
Member Avatar for yheenzie.saldivar

ASAP PLS..TENKS WOOF! NO PRAPLEM. #include <iostream> #include <cctype> #include <algorithm> using namespace std; int main() { string answer; do { cout << "Enter \"y\" or \"n\": "; getline(cin, answer); // Trim whitespaces before/after input. We tolerate those. answer.erase(find_if(answer.rbegin(), answer.rend(), not1(ptr_fun<int, int>(isspace))).base(), answer.end()); answer.erase(answer.begin(), find_if(answer.begin(), answer.end(), not1(ptr_fun<int, int>(isspace)))); if (answer.size() …

Member Avatar for clubberlangMayo
0
97
Member Avatar for kshahnazari

I don't really understand what you're trying to say, but can the arrays be modified? Or must their content remain in-place? If the first I'd probably sort and compare if based on that. Something like this: (something quickly made, not tested) #include <iostream> #include <algorithm> using namespace std; bool SortedIsPartOf(int …

Member Avatar for mrnutty
0
231
Member Avatar for Alexkid

Will your ID determine which of the two types the struct value is? Or do you have special guard values? I'd first consider if storing them like this is what you want. (You could use two containers) Do you need the type-specific values, or it is only the ID you're …

Member Avatar for Gonbe
0
268
Member Avatar for asad393

You know that a linked list is basically a value and a pointer to the next element in the list. (if any) So somewhere you define what the starting point of your linked list is. (the head) With that you can access every element in the list by using the …

Member Avatar for Gonbe
0
357
Member Avatar for Huxaifa

I don't really get what you're trying to describe. What do you mean by "the probability of Malik"? The probability of what? From what you're describing it seems to me that you just want to count how many times every name occurs, pick the one with the highest occurrence (question: …

Member Avatar for L7Sqr
0
148
Member Avatar for dangkhoaddt

> have any ways to solution this problem? please help me get some idea.Now i dont have any good ideal for this problem. How about you read the replies? There is no solution to your problem because it's not possible to do what you want. Add another argument to "func" …

Member Avatar for dangkhoaddt
0
202
Member Avatar for munchlaxxx

char first[100], last[100]; Why use character arrays when you can use string objects? Change this to: string first, last; cin >> first, last; Is incorrect. You're applying the [comma operator](http://en.wikipedia.org/wiki/Comma_operator) here, which is why it compiles. The following will do what you're probably expecting: cin >> first >> last; You …

Member Avatar for Gonbe
0
2K
Member Avatar for serita.v.campbell

printf("\nFile Will Not Open!!!!\n); You are missing a terminating quotation mark. Also I would be very scared if an application would respond to me using so many exclamation marks, but this is not technically an error. printf(\navg is beint calculated!!!"); You are missing the opening quotation mark. Void open(void); "Void" …

Member Avatar for Gonbe
0
208
Member Avatar for CHOCHOCHO

As far as trimming goes, the following might be useful: // Trim the start of a string. string& TrimLeft(string& s) { s.erase(s.begin(), find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace)))); return s; } // Trim the end of a string. string& TrimRight(string& s) { s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end()); return s; } // Trim …

Member Avatar for Lucaci Andrew
0
373
Member Avatar for vmanes

I'm pretty sure the std::string overload was added in C++0x. I can only imagine they didn't add it earlier o prevent a dependancy between the <string> and <fstream>. I haven't been able to find an official statement about why they made the choice to add it in C++0x, although I'm …

Member Avatar for NathanOliver
0
1K
Member Avatar for pooja.singh.3950

Your GCD function will divide by zero when you enter 0 as its second argument. You can also supply negative numbers. You're lacking return types as well.. I assume that you don't feel the need to check your arguments as you have full control over them. You should still assert …

Member Avatar for Gonbe
-2
170
Member Avatar for Hey90

> Yes this works but I have been asked as a task to do: That task just makes no sense. To get this straight, you've been given this piece of code: New(Shoe[num], num); And you're supposed to make that work in a way that it adds a new element to …

Member Avatar for Hey90
0
188
Member Avatar for hg_fs2002

You are applying "&" to an array variable. This works differently from pointers. It gives the memory address to the first element, so basically it can be considered int*. (cast to) Something like this will work as you'd expect it to: #include <stdio.h> int main (void) { unsigned int i …

Member Avatar for Ancient Dragon
0
102
Member Avatar for guy21

There's a bunch of things to be said about your code. Below is your code with some comments, I didn't change anything though. #include <iostream> #include <string.h> // C-header, iew! using namespace std; int main() { // We're using C++, use a string object instead of a char array. char …

Member Avatar for guy21
0
116
Member Avatar for billionair

There's some edge cases that could make it somewhat complex. Mostly because you could have lines bigger than your buffer. This will result in two types of reads: those that end in newlines, and those that do not. (and a newline happens to be exactly the symbol that marks the …

Member Avatar for deceptikon
0
1K
Member Avatar for christinetom

The term "pointer to arrays" could be somewhat misleading, depending on how you interpret it. Just as a heads-up: pointers and array aren't the same thing. One example that illustrates this: #include <iostream> using namespace std; int main (void) { const char* pointer = "Hello world!"; const char array[] = …

Member Avatar for Gonbe
0
145
Member Avatar for christopher.magalso

Haha, I love how you thank deceptikon for his advice to "do anything" as if it's something you hadn't considered previously. Good luck!

Member Avatar for Gonbe
0
253
Member Avatar for kidpro

You're very close. You do have to pay better attention to the loop range however. Below is a fixed version of your code where I kept the changes minimal. The comments should speak for itself: #include <stdio.h> #include <string.h> int main(void) { int loop,count; char* string = "myname"; // The …

Member Avatar for Miorfs
0
160
Member Avatar for code_r

Your code doesn't take leap year into account, and "magic numbers" are generally a bad idea. (Although they are unlikely to change in this case..) You could try something like this: #include <iostream> #include <cassert> using namespace std; enum Month { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, …

Member Avatar for Gonbe
0
138
Member Avatar for muhammad.khan.3576

C-string don't automatically grow. You have to be aware of the array's dimensions. Why don't you use 'string' objects instead as we're talking about C++ here?

Member Avatar for Gonbe
0
143
Member Avatar for ThatJamaican

Note that a palindromes don't take punctuations and word dividers into account. For example: > Bush saw Sununu swash sub. is a palindrome, although your application would say it's not. These types of problems are easy to think about recursively. The general idea would be that 'the first and last …

Member Avatar for Gonbe
0
263
Member Avatar for Tsaou

I find your code pretty difficult to read. Why don't you divide problems into a smaller problems by using functions? I don't really know the theory behind perfect numbers that well but on a quick attempt I would go for something like this, which is quite different and (in my …

Member Avatar for Gonbe
0
319
Member Avatar for Starship12

> so I spent 3 days trying to make the program and still have it not done yet :( vs > I've done nothing and that's the problem :( Hmmm.. Anyway, what are you supposed to use? I guess you want to implement it using an array or linked list? …

Member Avatar for NathanOliver
0
121
Member Avatar for Ahmad1797

#include <iostream> #include <cassert> using namespace std; void Repeat (const char symbol, const int amount); int RowToWidth (const int row); int ObtainHeight(); int ObtainHeight() { int height(0); do { if (cin.fail()) { cerr << "Invalid input.\n"; cin.clear(); while (cin.get() != '\n'); } cout << "Enter the height of the pyramid: …

Member Avatar for Gonbe
0
106
Member Avatar for akashi

> Now I need to do the validation for( date and madein). (1) to decrease 10% of price if date before January 2012 (2) to add 10 Rm if the madein country is Malaysia. stuck again! Why? If you have a day, month and year what is stopping you from …

Member Avatar for spuriousgeek
0
122
Member Avatar for kmachstang

It wants an array of bytes and extracts a "length" value from that array by combining the bits in the second and third byte to form a 16 bit integer. (later stored in a 32 bit one..) The most significant part of this 16-bit integer is formed by the third …

Member Avatar for kmachstang
0
174
Member Avatar for mitchell5879

I am a little bit confused as to what output you want your program to have, or rather what it is supposed to represent. You don't really seem to want substrings as you also mention "ac" but you do not mention things like "cb". Would "cb" be the same as …

Member Avatar for zhizu
0
174
Member Avatar for maraghuram

People are using the term "leaf" differently.. A leaf node would be a node without any children in my book. I assume you just want to delete any node from your tree, meaning you could delete the leafs too if you wanted. > I am trying to delete the leaf …

Member Avatar for Gonbe
0
788
Member Avatar for rajeshyadav6382
Member Avatar for code_r

I think the memory representation "images" are vague but I'll try anyway: 1. Answer should be "a". You answered B. That would result in an array consisting of 3 pointers to "Foo" objects in memory, so that would be [Foo*][Foo*][Foo*] according to the notation used in your example. (I think) …

Member Avatar for Gonbe
0
168
Member Avatar for nitin1

What does your design look like at the moment? (How are you handling multiple clients on the server? Threads, I/O multiplexing? You could apply the same solution on the client side to detect incoming messages and send things at "the same time" (not really ofcourse).

Member Avatar for nitin1
0
2K
Member Avatar for ayesh.yousaf

The supplied piece of code isn't wrong. If it's not working it is something else within the program that is causing issues.

Member Avatar for nullptr
0
95
Member Avatar for prathiyus

Try to do it with 1 array first. There is no added value when working with two, and with your code you lose track of how many elements A contains. Your code also doesn't compile. (You call swap with 2 arguments while it has 3 for example) Try to explain …

Member Avatar for prathiyus
0
338
Member Avatar for Elixir42

You could try something like this: #include <iostream> #include <sstream> #include <limits> #include <iomanip> std::string double_to_string(const double value) { std::ostringstream stream; // Go for maximum precision and take into account that converting could fail. if (!(stream << std::setprecision(std::numeric_limits<double>::digits10) << value)) { // Possibly throw an exception instead. return std::string(); } …

Member Avatar for Elixir42
0
3K
Member Avatar for kikechithomas
Member Avatar for jcmoney1010

for (i=0; i<Number_entrys;i++) { scanf("%s",names); } You are looping here to obtain "number_entrys" entries, but you do not use your counter. Change it to this: for (i = 0; i < Number_entrys; i++) { scanf("%s",names[i]); } I'm also not sure what the goal is of this statement: printf("%s",names); But be …

Member Avatar for jcmoney1010
0
164
Member Avatar for Mncedisi

Typical case of TL;DR but I did notice the following words: > A text-based menu driven program should be created. Could try there I guess.

Member Avatar for Iyfjeyeon
0
182
Member Avatar for RAPTOR88

> int &count That is not allowed in C. Reference parameters are C++, use a pointer instead. > const int MAXSIZE = 100; > char line[MAXSIZE] = {'\0'}; I think this falls under "variable length arrays" (VLA's) which is a C99 feature. I'm not entirely sure because of the const …

Member Avatar for Gonbe
0
152
Member Avatar for TheNotoriousWMB

How about you first create a class representing a linked list that contains some basic operations? * Insert a value at a given index. * Remove a value at a given index. * Obtain the size * Get the value at a specified index ([] operator?) * Remove the first …

Member Avatar for Gonbe
0
284
Member Avatar for highonbikes

> let me know if anyone has any pointers thankS! 0x0F021016 0x0E031418 0x08051033 *Ba dum tss* > any help would be greatly appreciated!!! thanks! Anyway, at a quick first glance I don't really see anything that could cause errors. What have you established yourself already? At what point do problems …

Member Avatar for Lucaci Andrew
0
153
Member Avatar for kieranrea

It is because of this line: scanf("%c", &yesno); This will also read '\n' when pressing return in addition to whatever you entered. On the next iteration this will still be in the buffer so that statement will read that directly. It fails the input check so the next iteration is …

Member Avatar for somjit{}
0
159
Member Avatar for Ankit.duke

Hmmm... I think i'd start like this, just an idea though. int main(void) { return 0; }

Member Avatar for Despairy
0
82
Member Avatar for HunainHafeez

Such C++ includes in C code. The way you do it will become problematic when using 48 bits as the amount of possible permutations is huge. You don't have to store them though and just output them as they get calculated. Another thing that might become an issue is the …

Member Avatar for HunainHafeez
0
270
Member Avatar for chandan127

It's not skipping input, you already supplied it. Say you enter 1 for the 1st number. What you really enter is: '1' and '\n'. The '1' is read into 'a' and the '\n' remains in the stream. When calling scanf() a next time it reads the newline character that was …

Member Avatar for zeroliken
0
768

The End.