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

Invisal: line 3: x can not be both at the same time. It should have use the || operator, not && :)

invisal commented: Thanks for point out +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm not upset about your question -- something like that comes up every once in awhile, and I just remind people that the mods here are not paid, we do it because we want to.

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

Welcome to DaniWeb Julian.

>>i was wondering if this was a entry level course or do i have to do a course prior to this
You will have to ask your college counsler about that because every school is different. Look up that course in your college course book and it will tell you what the prerequesits are.

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

>>If an admin could edit that, that would be great
fixed -- I hope :)

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

depends on your compiler. The only compiler that supports graphis.h is old 16-bit Borland such as Turbo C. If you really want to learn c++ program then trash that compiler if that's what you are using and get a free modern one. Afterall, you can't learn to drive a car by riding a horse.

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

>>the privilege of getting one query answered by a PM by one of the Mods
Most of us work here volunteerly, meaning without pay. If you want to get answers via PM I'm sure there are paid sites where you could ask them. Shoot, deposit $200.00 USD in my pay pal account and I'll answer one question via PM.

Other privilege is getting those gold stars under your user name and the little green things called reputation points. You are awarded a gold star for every 1,000 posts.

Donations come with priviledges, see the link for a list of them.

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

why can't you create the pointer? what error(s) do you get? And no, you can not use the class methods (unless they are static methods) if you can't create the object.

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

do you mean something like this:

class A
{
   // stuff here
};

A* ptrA = new A;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome to DaniWeb EchoQuiet -- wow! not many people write a novel as their introduction. But interesting reading. Hope to see you around alot, especialy in the Web Development boards.

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

Welcome to DaniWeb la1 -- but please leave your crumbs, drops and goop at work before posting :)

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

Welcome to DaniWeb polaris. Hope to see you around.

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

worked for me. Here's the code I used. I made a minor change at line 291 but that was only for debugging. There are several other problems that I didn't mention, such as use of gets() function. You should use fgets() instead because gets() can destroy your program if you type more characters then the input buffer can hold. For example: Acct is 6 characters, try typing this number: 123456789012345 <Enter> and see what will happen.

#include   <stdio.h>
#include   <string.h>
#include   <stdlib.h>


#define MAX 100


int menu(void);
int display(int i);
void customer_search(void);
void AccNo_search(void);
void enter(void);
void save(void);
void load(void);

struct catalog
{
       char name[80];
       char AccNo[6];
       char address[80];
       unsigned date;
       unsigned char month;
      
}*cat[MAX];

struct bank
{
        char BankName[20];
        unsigned LastAccNum;
        unsigned sortCode;
        
}*bank[MAX];

int top = 0;


int main(void)
{
              int choice;
              
              load();
              
              do
                {
                         choice = menu();
                         
                         switch(choice)
                               { 
                                       case 1: enter();
                                            break;
                                       
                                       case 2: customer_search();
                                            break;
                                            
                                       case 3: AccNo_search();
                                            break;
                                            
                                       case 4: save();
                               }
                }
       
       while(choice !=5);
system("PAUSE");
       return 0;

}   
            
            
            /* Return a menu selection*/
            
int menu(void)
{
    int i;
    char str[80];
    
         printf("\t\n\aEircom Billing System\n\n");             
         printf("1->Add Customer\n");
         printf("2->Search by Name\n");
         printf("3->Search by Account Number\n");
         printf("4->Save added Customers\n");
         printf("5->Quit\n");     
              
           do
                {
                                 printf("Make your selection:  ");
                                 gets(str);
                                 i = atoi(str);
                                 printf("\n");                        
                } while(i < 1 || i > 5);   
                
           return i;
}                    
                                      
    /*Enter customer into file */
    
    
void enter(void)
{
     int i;
     char temp[80];
     
     
     for (i = top; i<MAX ; i++)
            {
                                    
                   cat[i] = malloc(sizeof(struct catalog));
                   
                          if(!cat[i])
                                 {
                                                 printf("Out Of Memory\n");
                                                 return;
                                 }
                  
                 printf("Enter customer name …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The ascii value of '0' is 48. So the values of row and col on lines 24 and 25 are 48 and 46 respectively. That means the switch on line 26 doesn't do anything because the value of 48 is not one of the case statements. Next, line 52 reads outside the bounds of the array dimensions, so it will return some random value.

[edit]^^^ What Danger said[/edit]

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

line 87: never ever use gets() for anything because it can overwrite the input buffer and cause your program to crash. Instead, use fgets() to limit the length of the text.

lines 292 and 293 need braces around that multi-line if statement. That's why your program just exits.

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

Maybe he cranky teacher wants a make file as well as all source files. You can't get a make file with visual studio -- VC++ 6.0 was the last compiler that created one, and then it probably couldn't be used by other compilers.

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

>>One problem is the the programs stops at a certain point which is noted in the code
Please identify the line number. Did you forget to mark it because I don't see it.

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

>>your meaness is not necessary
LOL: did you see my avatar? I'm not called Ancient Dragon for nothing :) We dragons are pretty mean critters. (That was supposed to be a joke, so please don't get mad about that statement)

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

>>do they contain anything in difference ???
Yes -- and IDE and a compiler and not the same thing. Is a dog and a monkey the same kind of animal?

>>if i get MinGW does it need any run time libraries that i would need to get ?
The download should give you everything you need, including the libraries

>>cant i just use visual stuido from the command line ?
Do I look like your teacher? You'll have to ask him. My guess is no, from the response you posted earlier about what he said.

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

. You were telling me earlier that 1000,100, 10, 1 could not be hard coded, but never told me why and how I can go about it..

I mean how many times do I have to say I know how to do the math to get the single digits to make up the fourdigitnumber.

You keep contridicting yourself. At first you said you didn't know the math and now you say you do ??? Don't get mad ad me if you fail to explain yourself.

In any event, I'm not going to just hand over any more of the problem because you already have eveything you need to complete the assignment. If you are still confused about something then maybe you should re-read your textbook and the notes you took (or should have taken) in class.

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

Why? simple 4th grade (or thereabouts) math. Do the math with pencil & paper and it will become clear to you why you have to do it that way. The main reason why is to get the individual digits from left to right -- 1234 becomes 1 2 3 and 4. So 1234/1000 = 1, then 234/100 = 2, and 34/10 = 3, finally 4 / 1 = 4.

>>and how I can go about it.
Yes I did in my post # 8

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

An IDE is just a visual interface for a compiler. Visual Studio C++ is an IDE and a compiler. When you select Build in the menu the IDE invokes the compiler to compile the program.

I suspect what you teacher wants you to use is a command-line only compiler such as g++. If he wants you to use a specific compiler then he should have told you which one to use. MinGW is commonly used

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

After a little testing it appears that the c++ doesn't support fstream in that error class when used in a throw statement. Comment out the fstream object and it the program compiles ok. I'm not enough of an expert in this to tell you why that is happening.

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

or try this if( x > 0 && x < 5)

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

i know that is for c++ but can i ask what is the code of this in vb6?

You can ask but you won't get an answer. Ask the question in the VB6 board. Besides, I don't know the answer either because I don't write VB6 code.

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

>>And Im not saying he didn't I know what the % mod means
The mod operator % returns the remainder after division. Example: 1234 % 10 = 4 because 1234 / 10 = 123 with a remainder of 4. When we do integer division there are no decimals -- they are normally just dropped without rounding.

As JRM indicated you already have everything you need to complete the assignment.

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

>>Does this look right?
1000 can not be hard-coded because it changes on every iteration of the loop. The second iteration it will by 100, then 10 and finally 1 on the last loop.

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

see post #8, but you will have to remove the actual c code/calculations as your instructions say.

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

I suppose it might be something like this:
step1: start a loop
step2: extract a digit
step3: remove the digit from the original number
step4: display the digit
step5: go back to setp 2

>>And then I have to Transform steps in solution algorithm (pseudocode)
You can deduce the pseudocode from what I've already posted.

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

I suppose you could do it this way too, which will display the digits in the correct order

int modop = 1000
while number > 0
    digit = number / modop
    number = number % modop
    modop = modop / 10
    display digit
end while
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

no no. take what I posted and put it in a loop. This will display the number backwards though.

enter a 4-digit number
while number > 0
    digit = number % 10
    number = number / 10
    display digit
end while
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

dir will just tell you where iw3mp.exe is. You have to copy that directory into the next line. Its possible that it isn't even on your computer. I'm using Vista Home Premium and I don't have it in the windows directory.

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

in a loop you use number % 10 and number / 10. for example assume number is 12345
number % 10 = 5
number / 10 = 1234
number % 10 = 4
number / 10 = 123
etc.

>>How would I Put the Major task (P in the IPO) into words
I have no idea what that is.

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

after inputting the number start a loop that uses the mod operator % to get the last digit of the number and then divide the number by 10 until the result is 0.

Or input the number as a character array then simply display each character on a separate line.

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

If you run the program with that change I suggested it should work ok.

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

>>I need to get some dos here that automatically finds the iw3mp.exe folder
create a command prompt window, cd to the root directory, most likely c:\, then type "dir /s iw3mp.exe".

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

>>read 20 pages and didten understand any thing
yes, it takes some studying for that material to sink in. Re-read and do all the questions at the end of each chapter. Practice makes perfect.

There are several free compilers you can use. One is Dev-C++, which is probably the easiest to learn how to use. Another is VC++ 2008 Express, which is more complicated but I think a better compiler. For beginners I would recomment Dev-C++

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

This is not a standard MFC class so you will have to read the docs from wherever you got it. Most likely from here.

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

Sorry buddy this isn't a sofware warehouse. YOU write the code and we'll help. But you could try googling to see what you can come up with. But be forwarned -- such a program is not easy and requires a solid understanding of C or C++ language to understand. In your case -- forget it.

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

line 34: the first parameter to strtok() is supposed to be NULL. It should be a valid string only the first time strtok() is called, which was on line 33.

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

how much C or C++ experience do you have? None? Then start at the beginning, buy or borrow an introduction book and start studying from page 1. In 6 months or so you will have enough knowledge to answer that question yourself

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

>>But we can only pay attention to, absorb so much. After that, it's just white noise. Are we hearing any more than we did before? Is the quality any better?

I never ever read blogs (at least not that I know of), so I don't have that problem. It seems like it would the similar to many people who have a cell phone embedded in their heads. I don't use one of those either. I can get along just grand without either of those modern marvels.

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

Well, that sure is a dumb way to write a problem unless the reason for it is to demonstrate how well you know arrays. No one in his/her right might would write a program llike that in the business world.

At any rate, I suppose the other three arrays are similar to that one ? Such as, the starting address of the name array can be calculated as the address of the first record in the array + (account number - 1000) * MAX_NAME_LENGTH.

The first thing you need to do is declare the arrays

unsigned char accounts[512*sizeof(int)]; // room for 512 account numbers
unsigned char firstnames[512*10]; // each first name is 10 characters
unsigned char lastnames[512*15]; // each last name is 15 characters
unsigned char money[512*sizeof(float)]; // 512 floats

To access the above just use the formulas I already posted in my previous post.

Next thing is to declare ifstream object and read the file into those arrays. Read your text book to see how to do it. There are also hundreds of examples right here on DaniWeb.

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

>>The starting address of any element in the account array can then be calculated as the address of the first record in the array + (account number - 1000) * sizeof(int).

Are you certain about that statement ? That would imply that all those account number integers are contained in one large character array, not an array of integers.

unsigned char accounts[2048]; // room for 512 account numbers

// to store an account number
int acctnr = 1015;
memcpy(&accounts[(accnr-1000)*sizeof(int)], (char*)&acctnr, sizeof(int));

// to retrieve an account number
memcpy(&acctnr, &accounts[(accnr-1000)*sizeof(int)], sizeof(int));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ExitWindowsEx() win32 api function. The second parameter shown below can be any one of several reason codes -- see the link for other reason codes.

string str = "Quit";
...
if( str == "Quit")
   ExitWindowsEx(EWX_SHUTDOWN, SHTDN_REASON_MAJOR_APPLICATION);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you'll have to post the code surrounding that error. Could be a missing header file, or any of another 1,000 reasons.

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

>>cant detect well the problem..
Neither can we since we can't see your computer's monitor and code.

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

string.h is for C programs, not C++. The std::string class is declared in <string> header file

#include <string>

using namespace std;

>>what is the syntax for string
Here is a complete list of string functions

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

Here is some info that may be helpful to you

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

Welcome to DaniWeb -- I hope you read the RULES which state we do not do your homework for you. Show us what you know how to do and we'll help with the rest

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

So, the file you are working with is a binary file, not a text file? Here is one way to code it using memcmp()

unsigned char buf[] = <some binary data>
int bufsize = <size of buf in bytes>
unsigned char search[] = <binary representation of an integer>

// now search buf for a specific int value
for(int i = 0; i < bufsize; ++i)
{
    if( buf[i] == search[0] )
    {
          if( memcmp(&buf[i],search,sizeof(int)) == 0)
          {
                 // found it
           }
    }
}