1,362 Posted Topics
Re: Please show us some work, ask questions. Then you'll get some help. | |
Re: Several comments, I hope you will be able to use them to improve your code. First, you say you are not to modify the input array, but you keep storing the largest found value at index 0 of the array. Better to allocate variables to store the largest value and … | |
Re: If I understand your question correctly, you want to modify the program to pass two values to the function, both to be modified, and get the two new values back in main? For that to happen, you're going to have to pass at least one of the two arguments by … | |
Re: Look at the relationship of your line 7 and line 9. How does index relate to the bounds of the array? for (int index = 0 ; index < size2; index ++) if (sorting_array[index] > sorting_array[index + 1]) | |
Re: You will also need to subtract 1 from the length to get the index of the last character. | |
Re: I think the test in line 32 is unneccessary. If either X or O had won, you won't get to that test. If neither has won, then you should do the completed game test as the else action. Initialize the winner variable to the not complete value. When the if..else … | |
Re: Even char is not strictly defined as one byte, by my reading of the standard. > Objects declared as characters (char) shall be large enough to store any member of the implementation’s basic character set. Could there be an implementation that uses a larger character set? | |
Re: In Visual C++ 2012, it works for me. In that environment, there's a compiler option to treat wchar_t as built in type. Project | Properties | Congifuration Properties | C/C++ | Language Yes (/Zc:wchar_t) | |
Re: I think it would help us to understand the problem if you showed what x[2] and [x3] should look like. From your sample, I don't see the pattern the problem is supposed to create. | |
Re: You marked this solved, but you're not really done. Line 64 in your search routine is not right. `if(array[lower] == num || array[ArraySize - 1] == num)` This tests the lower end index and the last value in the array (so what good is higher doing?) yet you then test … | |
Re: We don't do your homework for you here. You write some of the program, test it, write some more, test it.... When you encounter a problem, post your code and ask a question. Point to the part of the code you think is the problem, describe what it should do … | |
(and oldie, but a goldie) * Defensive programming? Never! Klingon programs are always on the offense. Yes, offensive programming is what we do best. * Specifications are for the weak and timid! * This machine is GAGH! I need dual Pentium processors if I am to do battle with this … | |
Re: Please read [this](https://sdsmt-ex13.sdsmt.edu/owa/auth/logon.aspx?replaceCurrent=1&url=https%3a%2f%2fsdsmt-ex13.sdsmt.edu%2fowa) first. We won't do your homework, we'll help when you encounter problems. Show some code, ask questions about it. | |
Re: For starters, I think you're off in setting the ptr `int** ptr = reinterpret_cast<int**>(&arr[0] + width * i)` If ptr is to point to the beginning of each "page" ( dimension specified by depth ) then you also need to multiply by height; `int** ptr = reinterpret_cast<int**>(&arr[0] + height * … | |
Re: It would help if you put the whole context here, rather than relying on reading a couple of your other threads. That said, I think the big problem here is you're trying to input to a function. And a function that returns a value without taking any argument. Perhaps you … | |
Re: (never mind, I see Moschops's answer is spot on.) | |
Re: You don't need the adress of operator (&) in your call to the 1D function. Just use the array name and index of the row. That is the address of, or pointer to, the row in question. ` calcNums(nums[1]);` | |
Re: How full would your head get with a 1000 years of experiences? I have trouble remembering last Tuesday as it is. AD: Social Security in 900 years? You really are a comedian, aren't you? | |
Re: Rather than set the lowest_found value to some abritrary high value, set it to the age of the first girl in the list. Then compare from the second one on. By setting the initial value to a valid data item, your code will be correct no matter what the range … | |
Re: It will depend in part on what type of data the file represents. If it is a plain text file, AD's method will work. If the file contains numeric values, the size of the file won't tell you how many numbers are stored. Your method would suffice to find the … | |
Re: With processes spawning processes, this hardly sounds like a simple assignment. And the hint your prof gave really doesn't even touch the tough parts. Show some work, ask some questions, and we'll be glad to give some help. We won't do your work for you. | |
Re: It would help to show a bit what the sample data file looks like. I'm betting you have numbers, which may be more than one digit? Your array is of type char, which holds one character per element. Perhaps you should change the array to type int? In your display … | |
Re: I don't see the user's guess actually being compared to anything. The test variable never gets set to anything, yet you use it to control the switch. Wait, do you mean the integer test that is global, or the Outcome test in main? | |
Re: Not explaining why the thing has turned into such a huge blunder (getting back to the original topic of the website), but here's a perspective on the issue I found floating the interwebz > March 21st 2010 to October 1 2013 is 3 years, 6 months, 10 days. > > … | |
Re: In your cal function, it looks like you only push single digits onto the stack, not the full value of any multidigit input. c=p2[i]; ..... default: { if(c>=48&&c<=57&&c!='c'&&c!='s') { Pushstack2(s,atoi(&c)); break; } | |
Re: Using the input method `cin>>name;` you only get one word's worth of input. The extraction operator will stop when it encounters whitespace in the input stream (blank, tab, newline). In order to get your full name, you need to use the getline( ). Also, you need to declare your variable … | |
Re: eBay and PayPal have a reputation lately of siding with the buyer - much to the detriment of some sellers. They should make it right. | |
Re: Multiple DUI cases are quite common. In my area, there was a fellow with 11 DUI convictions, maybe upwards of 30 some arrests. He was known as Mr. DUI. Looke him up! He died in a house fire, presumed to have started from cigarettes. Smoking Wile Intoxicated? You can suspend … ![]() | |
![]() | |
Re: Even if it doesn't cure or prevent cancer, it makes life more interesting. Bring on the curry! | |
Re: [QUOTE=RenjithVR;635734]you can use either cin.getline (name, '\n'); [/QUOTE] Oops - second parameter of the function is the size of destination array. If you want to use a (non-default) delimiter, you must still enter the array size. In your example, the getline would read in up the number of characters (less … | |
Re: Start by writing the code to read an input file. You can't really do anything else till that works. Decide if you want to read and store the whole file's worth of data, or read a line, process it, read the next... Show some work here, tell us what specific … | |
Re: if(( a[i][j]>= k ) && ( a[i][j] <= l )){ c[z] = a[i][j] ; z++; you are only putting the values between k and l into the c[] array, which possibly (likely) leaves many elements of c[] still at their uninitialized state. If your display of c[] is limited by … | |
Re: Please show us what you've tried, and explain just what you're trying to accomplish. I could dust off my lecture, or you could do a little searching. Googling "c++ 2D dynamic array" brings up several hits that look helpful. | |
Re: [code] rnum = (rand() % 50) + 1; if (rnum>1 && rnum <100) [/code] this is not doing quite what you want. rnum will be in the range 1-50. Your if condition will fail on value 1, which should be legitimate. You're on the right track to get your 1-100 … | |
Re: I'd take a higher throughput (CFM) over just higher speed fans. Larger fans can move more air at lower speeds, which makes them quieter for the same work. I've not looked at what's available in a long time, but I can attest to the usefullness of cooling pads. I had … | |
Re: You will need to write an override for == for your *extPersonType*, or revise your code to compare members of that type which are basic data types. | |
Re: Care to describe what your problem is? What should output look like, and what is you're actually getting. | |
Re: `maxValue(valArr[x],Size);//error here` You are passing a discrete value (an element of the array) to the function that is expecting the array iteself. Try `maxValue(valArr, Size);` | |
Re: You end the function with: y=y-1; cout<<y; float result; result=y; return (result); Your function is meant to return the solution, not display it, so you should remove the output statement. Secondly, why assign the value y to another variable, only to return that variable? How about, simply: y=y-1; return (y); … | |
Re: Your "indicator" is a single character, so why declare it as a string? Is it your intent that a user's message is just one line (no newlines)? If so, get an input then examine the first character of that to determine the processing needed. Something like if( input[0] == '#' … | |
Re: Like the story of the guy getting his physical exam. Asks the doctor, "will I live a long time?" Doctor: Do you smoke? Patient: No. D: Do you drink? P: No. D: Do you cavort with women? P: No. D: Then what the heck to you want to live a … | |
Re: Best? The one that's not causing me to pull out any more hair at the given moment. Overall, in the Windows camp I'd say Win7 is best of the lot. I like XP and have it on several boxes still (heck, I still have a Win98SE box in occaisional use). … | |
Re: To increase (or decrease) the value stored in an array element, just do the math. int data[5] = { 1, 2, 3, 9, 10 }; data[0]++; //increases the value by 1 data[1] = data[1] + 5; //adds some number to the element data[2] += 10; //shortcut operator //array contents now: … | |
Re: If you want to ask a question here, please ask it here. | |
Re: Looks right. Other than needing some `<< endl` and semicolons at the end our your output statements. |
The End.