Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Look at line 27 for example. indata is an INPUT stream and you are attemtping to INPUT a char* literal. Can't be done. input streams require variables to accept the data. If your intent is to write the strings and other data to a file then you need an OUTPUT stream, ofstream and use the output operator <<.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

did you compile the dll for DEUG ? Does your program use LoadLibrary() to load the DLL into memory ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

haha, I think it woulda have lasher.

Btw, why does everyone think Acer is cheap? I've seen plenty expensive ones from them.

They aren't cheap. But they are crap -- there is a difference :) I hope the manufacturer doesn't sue me for saying that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I remember that the path a compiler uses to find a header file is determined by the "Path" that you see when you type "path" on the command line.

Might depend on the compiler, but normally it looks in either the PATH environment variable or the path in the -I option flag.

>>How do you add a new path to the "path"on the command line? Isn't this what we need to do if the compiler cannot find a header file?
No. see above comment
<snip> -Ic:\Program Files\<rest of path here>

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

how is indata declared ? Is it a member of istream?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>When the money is added it gets added to the begBal not the current balance

In ProcessDeposit() why not simply add the transaction amount to the current balance?
Change line 15 to this: currentBal += transAmt;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

pretty simple -- just replace the array of ints with an array of structures and make temp a structure data type instead of int.

Not sure where you got that algorith, but its a little off -- the inner loop should run from i+1 to size. I think the below will run slightly faster because fewer iterations.

void sort(int arr[],int size)
{
  int temp,i,j;
   for (i=0;i<size-1;i++)
   {   
     for(j=i+1;j<size;j++)
    {  
        if (arr[i]<arr[j])
        {
            temp=arr[i];
            arr[i]=arr[j];
            arr[j]=temp;
         }
     }
  }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Nice code you posted -- why did you post it ? (my crystle ball is broken tonight)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

how about exit(0); or return 0; if called in main().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Minutes is calculated like this (I think). You have to subtract from original value of secs the number of seconds in hrs variable then mod the result with 60 (60 seconds in one minute).

secs -= (hours * sph);
minutes = secs % 60;

Now the remaining seconds is

secs -= minutes * 60;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you are close -- delete lines 36 and 46. Then delete the +1 from line 37 and the -1 from line 45. and line 45 should be min = computerGuess Finally, line 47 calculation is incorrect.

computerGuess = ((max - min)/2 ) + min;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your instructions say you must use a while loop. You will need two integers, one to count from 1 to whatever number you enter, and the other to sum up the values. Do it a little bit at a time so that you don't get overwhelmed. First how to create that while loop. After you get that done then add the counter to count from 1 to N. Only after that works do you worry about the sum integer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I am not familiar with the vector class string, but if you could elaborate on it a little I may be able to figure it out.
Thanks

See these code snippets.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I just don't know how to find the sum of the numbers between 1 and the number they entered

How would you do it yourself with pencil & paper? If I enter 5 then you want 1+2+3+4+5. Now do the same thing with a loop and two counters -- one counter is a loop counter and the other variable is the sum of the value of the loop counter on each iteration of the loop.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I bought an Acer a few years ago from Best Buy because it seemed to be a good idea at the time -- no screws that is. After I got it home, opened the case to add another card, I had a terrible time trying to get it put back together again. I kept that computer for about a year when I got so mad at it that I opened the back door and literally smashed it all over the concerte, along with the monitor :) I swore then that I would never ever buy another Acer, and swore to throw it at the first person who attempted to give me one.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Fidel Castro, I believe.

Yes, I know. Just attempting to be a little sarcastic. :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

no, they are not dictators at all. The President, Senitors, Congressmen and members of USSC do not have dictator powers. A dictator, by definition, can not be removed from office other than by dying -- whats-his-name from Cuba is a prime example. No one in USA is able to retain power forever without the will of the people.

You can't call an apple an orange.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>you could also use signature links
Yes, that's a good suggestion. Here at DaniWeb you can go to your Profile and add your links to your signature. Then do a whole bunch of posting in other threads to help others or in Geeks Loung just to talk.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 19: don't include the square brackets when passing variables, like this save_data (x,y,numpts); lines 23-29: you need to add open and closuing braces { and } to make all those lines part of that loop. Without those braces only line 25 is part of the loop

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

not necessary, just declare another int named count , initilize it to 0, then increment it in that loop maybe something like this:

for (i=0; i < MAXGRADES; i++, count++)

Then replace for (i=0; i<MAXGRADES; i++) with this for (i=0; i<count; i++)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> Is that why I need to change the counter?
yes, because the elements of the array that you did NOT enter contain random values. You should probably initialize the array elements to all 0 at the time it is declared like this

int grade[MAXGRADES] = {0};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

show us the code you have written so far. Do you know how to use vector class? That is the easiest array to use. You can make a vector of string objects

std::vector<std::string> theArray;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>either you use scanf("%c",&array[x][y]) or you use ("%s",&array[x][y]) is wrong.
The second form is certainly because %s is for strings not single characters. I don't understand why you think the first form is wrong.

I already told you how to resolve the problem. Here is the program that works All I did was add lines 7, 14 and 18 to flush the keyboard buffer of the '\n' character.

int main()
{
char array[3][3];
/* I want know somthinh here, in the each cell of this array does it take a charecter or a string*/
int i=0,l=0;
int x,y;
char iobuf[255];
 for(i=0;i<3;i++)
    {
       for(l=0;l<3;l++)
       {
         printf("Enter your index:");
         scanf("%d %d",&x,&y);
         fgets(iobuf,sizeof(iobuf),stdin);
         printf("\nEnter your value inside:");
/*I want to know here why the program stops running if I used %c in scanf as below and continue looping if I used in the scanf like this ("%s",array[i][l]);*/       
scanf("%c",&array[x][y]);
         fgets(iobuf,sizeof(iobuf),stdin);
        }
     }
//here to print the vlaues of the array
for(i=0;i<3;i++)
{
      for(l=0;l<3;l++)
          {
              printf("%c",&array[i][l]);
           }
   printf("\n");
}

return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try this:

if (grade[i]<0)
{
    cout << "This is not a correct grade";
    break; // exit the loop
 }

Also -- you need a counter to count the number of grades entered because there may be fewer than MAXGRADES. Then use that counter in the code that follows.

>>if (MAXGRADES>0)
That is an impossible comparison because MAXGRADES will never be anything other than what it is initialized to be at the beginning of the program. Instead of MAXGRADES you need to use the counter that I mentioned above.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post the rest of that function becase what you posted is not enough to tell us anything about the problem you have.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The flush function forces data to be written to a disk data file (or some other output stream).

There is a couple ways I can think of to solve your problem:
1. write each value to a file then read the values back and display them when the user is done.

2. Save the values in a vector or some other kind of array/container.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

google is a good place to start. Visit each college listed and see if they offer what you want. If you find some then visit them in person and talk to conselers. As long as they are accredited they should be ok.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you must have changed something. post new code where the problem is.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>//i want to call "displayReport" function i don't know how to do it

First you have to create an object of the class you want to use, then you can call its method(s). I don't see that function doing anything except displaying a welcome message.

GBook book;
book.displayReport();
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

do you know how to code bubble sort? or any other sorting algorithm ? If yes, then sorting structures is nearly the same thing except instead of swapping integers you swap whole structures. But it runs a lot faster if you use an array of pointers to structures instead of an array of structures because all you have to swap are the pointers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't reliably test for equality of floats due the the way they are represented in memory. May floats can't be represented exactly. So you can't reliably use the == operator. You might try something like this:

if( (newdeck > .449) && (newdeck <= .450)
{
   // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>but I don't know where is the wrong?
What does it not do correctly? I see a couple problems with line 17:

1. What happens if you enter a value for either x or y that are outside the range of the array? For instance, enter a value of 50000 and see what happens to your pgoram. You need to validate the coordinates before using them in line 17.

2. Can I enter the same coordinates more than once ? If not, what are you doing to prevent that ?

After every scanf() you need to flush the keyboard of the '\n' key that it leaves there as well as any other extraneous keys you might type. Unfortunately there is no really good standard C way to do it. My solution is to call fgets() with a char buffer.

char buf[255];
fgets(buf,sizeof(buf), stdin);

That too is not perfect solution but probably good enough for most programs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>and i have a problem in writing the main
If you really wrote the code you posted writing main() should be a breaze. So what is it about main() you can't (or won't) do ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> run(v1, v2, v3, v4);
you are attempting to pass the variables by values instead of by reference (pointer). Put an ampersand & in front of each variable to make them pointers like this run(&v1, &v2, &v3, &v4);

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
for (i=0, i < 3001, i++)
{	
    A[i] = i
}
	
for (i = 1, i < 30,i++)
{
    int j;	
    for (j = i+i; j < 3001; j++)
    {
        if (A[j] != 0)
        {	
              A[j] = 0
        }
    }
}

Ok here's the c code -- but still confusing so don't blaim me if its wrong :).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Could any body else tell me what I should revise if I want to use pointers or reference for input?

Nothing. Its already coded by reference because its not possible to pass an array any other way (pointers and references are essentially the same thing, although there are a couple minor differences).

If you really want to I suppose you code code it like this

double Ratio(double* a, double** VA, int i)
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I posted the following in the stickied book thread as it seemed the most appropriate place for it. That was 2 days ago and no one responded so I probably guessed wrong

Yes you were wrong to post it there so I deleted it just now because of this thread. You get a lot faster response by creating your own thread as you did here. I don't think those Read Me threads get read very often.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I am still confused -- you are ompiling your program for UNICODE but want to use char* instead of wchar_t* ? Then why compile for UINICODE ? Why not just compile the normal way ?

As I mentioned before all those functions have two versions -- one for wchar_t* and the other for char*. The function names you normally use are just macros which the compiler appends either W or A depending on the setting of UNICODE. You can explicitely do the same thing in your code and actually use both versions of the function in the same program. Example: So you see you are just wasting your efforts attempting to rewrite the win32 api functions, unless you are replacing them with standard C/C++ library functions for portability.

winbase.h

#ifdef UNICODE
#define GetFileAttributes  GetFileAttributesW
#else
#define GetFileAttributes  GetFileAttributesA
#endif // !UNICODE
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Line 23: should be y * y

delete line 22 because z has no purpose

move the open brace on line 24 to immediately after line 21 so that line 23 and 24 become part of the same for loop.

replace the C language function on line 31 getch() with the C++ function cin.ignore().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you are sorting the same array first in ascending order then again in descending. You need to reorder lines 28-31 so that it first sorts, prints, sorts again, then prints the second time. In orderwords line 30 should follow line 28.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Opening a database is expensive in terms of both time and resources. So the fewer times you have to open it the better performace your program will achieve. I would opt for option #2. Of course one problem is that you may need to tell the database server to flush the data to disk often. But a good database server will probably do that anyway. The programs I worked with each user had his/her own connection, for security reasons. The connection was opened when the user logged onto the application program and was not closed until the user logged off. There was no more than 8 hours between logon and logoff (one 8 hour shift). One problem we had to overcome was accidental dropped connections do to network down or server down.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I suspect Iraq was better off before we went there -- a dictatorship, even though it may be seemingly cruel, is sometimes a better solution than democracy. There were no terrorists in Iraq under Sadaam, except of course Sadaam himself.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The loop beginning on line 8 will never ever execute more than once because of the return statements on lines 16 and 18.

>>&& 2 == b - a ==> line 23
That will not work when the value of a > b. You need to consider someone entering 5 and 3 instead of the other way around.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>return *( static_cast< const char* >(pointer_to_non_null_cstr) + 1 ) == 0 ;
As a general rule that will not work because many languages take up two or more bytes. In *nix the wchar_t is a long integer (4 bytes) while in MS-Windows it is a short integer (2 bytes). And the last time I read the UNICODE standards board there was some talk about expanding it to 128 bites so that it can hold the graphics use for chinese characters.

This site has some good information you may want to browse.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>anyone can help me
Probably yes -- post your code and we'll see if someone can help figure out your problem

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

But remember that it only works for positive numbers. Enter all negative numbers and it doesn't work because of the initial value of number

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1. Delete line 15.

2. Delete the semicolon at the end of line 16

3. No need for variable count so delete it on lines 6, 10 and 18.

4. initialize value of number to 0 on line 5 because its used on line 11.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

please post the exact code that you wrote. There is no way that the code you posted can produce that output. Just copy it from your program and paste it to here.

>> y=x*z;
And what exactly is that supposed to do? what is z? You can't just toss a bunch of random variables at a program and expect it to work. Programs are executed from top to bottom, so you must code it in the order you want it to be executed. The loop goes first and then the line that does the calculations. I already posted an example of how to do the calculation. If you want to use y as the loop counter, great. Then in the code I posted just replace x with y.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In that case assume TCHAR* is all wchar_t*. You have to call special conversion functions to convert wchar_t* to char*. Which win32 api functions do you want to change?