344 Posted Topics

Member Avatar for wids101

Fix: line 19, flase should be false line 32, should be lo = mid; line 49, should be }while(toupper(reply) == 'Y');

Member Avatar for wids101
0
207
Member Avatar for ShEeRMiLiTaNt

Exactly as Bob suggested, just fill in the blanks. void Reverse(char entry[ ], int length) { if (0 == length) // if (!length) return; char *front = &entry[0]; char *rear = &entry[length - 1]; char temp; while (front < rear) { // swap front/rear // increment front ptr, decrement rear …

Member Avatar for ShEeRMiLiTaNt
0
201
Member Avatar for Perry31

1. Define what a 'simple project' is. 2. Once you've established what your project should do, I'm sure Googling would present you with many ideas and types of algorithm.

Member Avatar for rithish
0
76
Member Avatar for Tinnin

Have a look from lines 13 to 16, you're writing beyond the bounds of the allocated array.

Member Avatar for Tinnin
0
116
Member Avatar for Macilath

This should work. bool Backup::runBackup(std::string source, std::string dest) { char destPath[MAX_PATH] = {0}; char sourcePath[MAX_PATH] = {0}; // Note: source and destination paths must be double null terminated errno_t error = strcpy_s(destPath, dest.c_str() ); if (0 != error) { // handle error return FALSE; } error = strcpy_s(sourcePath, source.c_str() ); …

Member Avatar for nullptr
0
1,000
Member Avatar for Ouss

I'll get you started with a function skeleton - show what code you come up with if you have problems. int multiple(int first, int second) { // fill in the blanks // how do you determine whether first divided by second gives a remainder of zero? }

Member Avatar for Sendy Hipo
0
306
Member Avatar for abhishekagrawal

Commented where I thought necessary - untested /*program to find a number in the range 1 to 100 that has the largest number of distinct divisors*/ #include <stdio.h> #include <stdlib.h> int main() { //note: excludes divisors of 1 and the number itself int countstore[101] = {0}; int result, i, num, …

Member Avatar for nullptr
0
200
Member Avatar for coutnoob

In line 18 you haven't defined the operator. Try friend ostream &operator<<(ostream &mystream, Circle &c);

Member Avatar for histrungalot
0
351
Member Avatar for jeav12
Member Avatar for deceptikon
0
94
Member Avatar for srinivasdama
Member Avatar for Suzie999

> How can I eliminate the "high, reserved byte" or ensure it is set to 0? color = GetPixel(hdc_, 10, 10) & 0xFFFFFF;

Member Avatar for Suzie999
0
2K
Member Avatar for basom

To generate integers between 10 and 40 inclusive you can use: rand()%31 + 10; By N DISTINCT random integers, I assume that it means N different integers. So you'd have an array[N] and keep generating random range numbers, check if they're already present in the array and if not place …

Member Avatar for nullptr
0
350
Member Avatar for abhishekagrawal

Here's an implementation of your algorithm in c++. int BestSquareMatch(int i) { if (i == 0) return 0; if (i < 0) return -1; // error undefined int match = i/2; while (pow(static_cast<double>(match), 2) > i) { --match; } //increment to the last integer that satisfied the condition return ++match; …

Member Avatar for nullptr
1
249
Member Avatar for hwoarang69

I just threw this together. It will move all zero values to the end of the array. Hope it helps. int iarr[] = {1, 3, 0, 0, 5, 7, 0, 0, 0, 9, 9, 6, 0}; int len = sizeof(iarr)/sizeof(iarr[0]); int i , j, idx; for (idx = 0; idx …

Member Avatar for Vish0203
0
6K
Member Avatar for iwanna mix-mix

As well as pyTony's suggestion, in lines 12 and 13 you are trying to open the same file twice.

Member Avatar for TrustyTony
0
194
Member Avatar for mrmikemike

From line 31: float max = 0; for (u = 1; u <= c; u ++) { if (max < input[u]) { max = input[u]; c = u; // ** means that c is updated to u, hence the loop will break, so discard this line. } } Also you …

Member Avatar for mrmikemike
0
163
Member Avatar for Valiantangel

It makes no sense to implement this as a 'for' loop, because the number of loops will vary depending on the integer you wish to reverse. This will work, but it really seems pointless: int x = 123456; int y = 0; for (int j = 0; ; j++ > …

Member Avatar for WaltP
0
112
Member Avatar for Valiantangel

printf("factorial of (%d) = %d\n", fact, result); printf("press Enter to exit\n"; getchar(); return (EXIT_SUCCESS); or do you mean: #include <stdio.h> #include <stdlib.h> #define fact 5 int main(void) { int i, j, result; int _fact = fact; for (j = 0; j < fact; j++, _fact--) { result = 1; for …

Member Avatar for TrustyTony
0
92
Member Avatar for iPanda

1. Remove (LPBYTE) from CreateFileMapping(...) 2. I'm guessing that you're wanting to do something with the mapped file, in which case you'd have: fileView = (LPBYTE)MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);

Member Avatar for BobS0327
0
1K
Member Avatar for NyQii
Member Avatar for eshray

Post the code that you written so far and describe which parts you're having problems with. You won't receive any help at this forum until you actually make a fair attempt to code your assignment.

Member Avatar for nullptr
0
115
Member Avatar for Pipinit

I'm not 100% sure I understand the question, but this seems OK and avoids any crashes. #include <iostream> using namespace std; int main() { int A[10][10], row, column; for (row = 0; row < 10; ++row) { for (column = 0; column < 10; ++column) { // avoid divide by …

Member Avatar for Pipinit
0
233
Member Avatar for DelphiGuy

Check out [IsZoomed](http://msdn.microsoft.com/en-us/library/windows/desktop/ms633531%28v=vs.85%29.aspx) function.

Member Avatar for nullptr
0
138
Member Avatar for pattilupwned

a more compact example , with some modifications. #include <iostream> #include <string> #include <ctime> void setSecretCode(char*); using namespace std; int main() { char code[5]= {0}; setSecretCode(code); cout << string(code) << endl; cout << "press Enter to exit..."; cin.get(); return 0; } void setSecretCode (char* code) { string colors = "RGBYO"; …

Member Avatar for pattilupwned
0
312
Member Avatar for Daigan

Did you set the value of y to 1 before entering the do/while loop? Also you have: if (y >= 1 && y <= 4) as far as I can see y would always be greater than or equal to 1, so there's no need to test that condition.

Member Avatar for Vish0203
0
159
Member Avatar for Rasool Ahmed
Member Avatar for nullptr
0
920
Member Avatar for FraidaL

You could also use - void TransformUppercase(std::string& s) { std::transform( s.begin(), s.end(), s.begin(), ((int(*)(int))std::toupper)); return; }

Member Avatar for triumphost
0
163
Member Avatar for alanso

You can start by reading the following: http://www.cplusplus.com/reference/iostream/ofstream/open/ http://www.cplusplus.com/reference/iostream/ifstream/open/

Member Avatar for nullptr
0
171
Member Avatar for SillyNoob

Though your code is not strictly c++, this cuts down on some unneeded code. int** PntrFunc(int** itemGiven) { **itemGiven += 500; return itemGiven; } int main() { int * pntr = new int; *pntr = 50; int ** mPntr = PntrFunc(&pntr); printf("result %d\n", **mPntr); delete pntr; "press Enter to exit\n"; …

Member Avatar for SillyNoob
0
234
Member Avatar for cplusfreak

The recursive call to main() at line 71 is not a very good idea. You'd be better off using a do/while loop. do { // main code body std::cin >> cont; } while (cont != 'y' || cont != 'Y'); return 0;

Member Avatar for thines01
0
158
Member Avatar for Valiantangel

Just taking the first part of the equation - 3x^3 To multiply you need to use * as in 3*x ^ is bitwise xor, do you really want to calculate 3 times x xor 3?

Member Avatar for zeroliken
0
79
Member Avatar for Hitman Mania

An example with no error checking or optimization. void squeeze (char c, char S[]) { int i = 0; int j = 0; char fwd[MAX]; memset(fwd, 0, MAX); for ( i; i < MAX; i++) { if ( S[i] != c ) { fwd[j] = S[i]; j++ } } memcpy(S, …

Member Avatar for jayarajtk
0
265
Member Avatar for hwoarang69

try this: int main() { char* array[4] = { "one", "two", "four", "nine" }; char* test = "four"; check(test, array); getchar(); return 0; } void check(char* test, char* array[]) { int i; for (i = 0; i < 4; i++) { if(strcmp(array[i], test) == 0) { printf("same string: %s\n", array[i]); …

Member Avatar for jayarajtk
0
121
Member Avatar for compsci91

The first arg will either be the program name or empty, it's the second arg that will contain "-verbose", so you'll need to check that argc == 2.

Member Avatar for nullptr
0
206
Member Avatar for ashboi

Just using the first example: y >> 16 & 0xFF0 // y is shifted right by 16 bits, then bitwise and with bitmask 0xFF0 e.g 0xBEEFC000 >> 16 = 0xBEEF 0xBEEF & 0xFF0 = 0xEE0

Member Avatar for rubberman
0
115
Member Avatar for compsci91

In your first post, when comparing two char pointers, you'll return the one with the higher memory address. In the second post, you're just comparing the first character of each string, which will return whichever character is alphabetically greater, though it's still not going to perform a string comparison. I …

Member Avatar for m4ster_r0shi
0
160
Member Avatar for ItsAdZy

A more compact version of your current code (untested) int histArray[10] = {0}; int minValue; int maxValue; while (terminalArray >= 1 && terminalArray <= 99) { minValue = 1; maxValue = 9; for (int i = 0; i < 10; i++) { if (terminalArray >= minValue && terminalArray <= maxValue) …

Member Avatar for ItsAdZy
0
225
Member Avatar for rezonk

> You required to write definitions for the given 4 function performing task in the program. Have a go at writing the functions, then post your code and explain what you're having trouble with. **when you post any code, select the code portion and press 'Code' in menu.

Member Avatar for nullptr
0
166
Member Avatar for bathtubbuddy

string nom[100]; int num[100]; int cla[100]; With the method used to specify the arrays, it's impossible to actually delete an entry in the array. It seems from your code that I briefly looked at, you're sorting the arrays, performing a binary search for a particular item and if found you …

Member Avatar for Lerner
0
213
Member Avatar for f4fjks

Check that the return value of the following is a valid pointer : OUTPUT_FILE = fopen(file, "a+"); // what is file?

Member Avatar for f4fjks
0
949
Member Avatar for Newbienoob
Member Avatar for Erushima
Member Avatar for kkb08

I haven't tested, but check where I've commented. for (i=0; i<sum; i++) { differenceSquared = pow(userArray[i] - mean, 2); // at this point mean is still 0.0 sumTwo = sumTwo + differenceSquared; } // call function to calculate mean mean = meanStandDev(sum, userArraySize); // mean calculated after it's needed

Member Avatar for nullptr
0
157
Member Avatar for pushpat

This should work for you. :) [CODE]#include<iostream> using namespace std; class base { public: virtual ~base() { } }; class derived: public base { public: ~derived() { } }; int main() { base *bptr_1 = new derived(); // should check that memory allocation was successful base *bptr_2 = new base(); …

Member Avatar for pushpat
0
145

The End.