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

It might be nice to have a thread that contains all the featured posters and the articles written about them. Sort of like a history book of featered posters. As it is now its not possible to read the intervies. Say I wanted to re-read SOS's interview -- not possible any more unless you know exactly which issue of the DW digest it was printed.

On second thought, maybe it would be more useful just to put a link to the DW digest that contains his/her interview on the member's public profile page.

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

>>It's also somewhat difficult to differentiate between a legitimate member making inane comments and a sig spammer.

I use post count and past posting history for that purpose. First time posters on PFO who make that kind of post get the post deleted, but not infracted or warned because there are no rules about it. If the poster has made otherwise useful posts in other threads then I'll leave it.

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

First thing is that you need a list of the items for sell and quantities on hand. You might have something like this:

class item
{
   std::string name;
   std::string upc_number; // prodct it, or barcode
   int quantity;
   float price;
};

Now create a vector of those for each item you want to sell.

Next you need another list if items that the customer is buying. The only things it needs are upc and quantity. When you print the customer's bill you can find product name and price by looking up the upc in the vector of products for sell.

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

I can't open that zip file, but make sure the data file is in the same folder as the source files. Your program should also check to see if fopen() succeeded, which it is not doing.

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

I compiled and ran your program without changing anything and did not get that error. It ran and produced this output file

The number 550 was read in

Maybe there is something wrong with your input file? Attached is the file I used

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

As I stated, to get back to the way the constitution is today. We couldn't get back to the Constitution if we ignored parts of it. I might be dictator, but a legal one with morals and scruples. And that would also mean restoring all States rights and giving the power to govern back to the people.

But of course that's only a fantacy and nothing will ever come of it.

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

That's a different problem. Which line is the error on? Post the exact error message.

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

In that case, use __int64 instead of int.

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

line 37: use == operator, not = operator. That is setting those variables to 0.

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

depends on the operating system. MS-Windows and VC++ 2010 have __int64 data type. Other compilers might support long long. VC++ 2010 allows long long but the compiler treats it as 32-bit long integer. If you are not sure what your compiler supports then just write a simple program to print out its size

#include <stdio.h>
int main()
{
   printf("sizeof(__int64) = %d\n", sizeof(__int64));
   printf("sizeof(long long) = %d\n", sizeof(long long));
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First thing to do is design the database. What will it contain for each customer? How will it be written -- binary or text ? I assume you want to just use a standard file instead of an SQL compliant database, such as MySQL or MS-Access, which would be overkill for your purposes.

Next design a structure that contains the information for each customer. This structure will be used to store data to the database.

After you have that finished, come back with more specific questions about your program.

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

>>I get an error whenever I try to run it.
What was the error?

>>x = (int*)malloc(length*4);

what makes you think the size of an integer is 4??? Maybe it is, and maybe it isn't. The size of an integer depends on the compiler you are using. A more portable way to write that is x = malloc(length * sizeof(int)); And notice that C language does not require the typecast like C++ does. So if your source code file name has .cpp extension then you are writing c++ code, not c code.


line 42: Depending on the values you put in the two arrays, summing p like that could easily cause integer overflow. Might be better to use a 64-bit integer to reduce that chances of that happening.

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

I would be president if I could also be dictator. The first thing I'd do is put all the bills that have been passed by congress and all the decisions of USSC (United Stated Supreme Court) since 1776 through the paper shredder. Let's start all over again with the Constitution as it stands today. Then I'd fire most of the President's cabinet members, and dismantal most of the federal government, except those agencies specifically mandated in the Constitution, which I think is just the military. Immediately withdraw all military from everywhere around the globe and immediately stop all foreigh aid everywhere. Nations can just learn to fight their own wars without USA aid, just like they did 200 years ago.

That, I believe, is pretty much what the Libetarian party wants to do.

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

you know you are old when you are Ancient Dragon

Me, Old??? Never. I know people half my age who are older than I am.

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

why don't you ask QT? Join their mailing lists. But my guess is that you can't because QT is cross-platform. If they added .NET support then it wouldn't be cross-platform any more.

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

you have to use the os GUI functions which depend on the os you are using. Displaying a progress bar with C language is a great deal more difficult than it is in java or many other languages.

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

Yes, it is true that the compiler produces 32-bit code, but that should not have been the problem. I also have 64-bit Windows 7 and never have a problem using 32-bit DLLs.

What version of VB are you tring to use?

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

Reading your original program again you don't need to use atoi. You have to call strcmp() to compare them.

if (strcmp(acc,"abc") == 0 && strcmp(password,"123") == 0 )
	{
		cout << "endl " << endl;
	}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what do you mean by "composition" ?

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

How much assembly do you already know? Its really probably not all that hard to do. You need to declare storage for four variables, a, b, c and d. First calcaulate c^2 (which is just c * c), and d^2 (d * d). store that result away somewhere. Then calculate a+b. Finally divide the result of a+b by the denominator previously calculated.

Will I write this for you? No. Its your homework, not mine.

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

.... You notice that your mobile has 1000 times the storage of your first computer... And 10 times your university mainframes!

Now that one is soooooo true :) The first computer I saw in my life was military in 1963. It occupied three whole floors of a 5 story building and had less memory than the computer I am now using, which sits on a desk.

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

how are you trying to compare the contents of variable Text to 123? Is 123 an integer or character array "123"? If its an integer then you will have to convert Text to integer. if( atoi(Text) == 123)

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

Sorry, I have no idea what you want.

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

DLLs are not registered. DLLs have to be installed in one of the directories that are in your PATH environment variable. Instead of cluttering up someone else's directories with your DLLs you need to create your own directory then add its full path to the PATH environment variable.

I think this article explains it

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

One way to do it is to check the agent array to see if it already contains an entry for the agent just read in from the file. If it already exists then just sum the sales and value into the respective sales and values column. something like this:

int FindAgent(int agnt, int maxrow)
{
   for(int i = 0; i < maxrow; i++)
      if( agent[i] == agnt)
         return i;
   return -1;
}

void display()
{
ins.open(in_file);
int total_agent[size];
//int total_amount[size];
cout<<"                 TOTAL SALES BY AGENT"<<endl;
cout<<"AGENT NUMBER     #SALES     VALUE/SALE     AMOUNT"<<endl;
int i=0;
int t=0;
cout<<fixed<<showpoint;
cout<<setprecision(2);
while(!ins.eof())
{
    int agnt, sals;
    float val;
    ins >> agnt >> sals >> val;
    int row = FindAgent(agnt,i);
    if( row < 0)
    {
       agent[i] = agnt;
       sales[i] = sals;
       value[i] = val;
       amount[i]=sales[i]*value[i];
       i++;
    }
    else
    {
       sales[row] += sals;
       value[row] += val;
       amount[row]=sales[row]*value[row];
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem is not related to atoi().

static int getdigit( int num, int position ) {

  int digit = num / (int)pow(10,position-1) % 10 ;

  return  digit ;

division by 0 problem. pow() is returning 0 probably because the second parameter to pow() is a negative number (the value of position is 0)

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

If you use MinGW then this thread may help you. Go to project options, linker tab, and add -static flag. But that flag didn't seem to make any difference with my small test program.

>>tell me a way to link to the .dll files I need without having them directly in the same directory as the .exe file

If they are not in the same directory as the *.exe file then they must be on one of the directories in the PATH environment variable. On Windows 7 (probably earlier versions of Windows too) click Start --> Control Panel. Then select System icon. In there you will find options to view and edit environment variables, including PATH. You can add another directory to the PATH or copy the dlls into one of the existing directories. Adding your own directory is ideal so that you don't clutter up someone else's directories with your dlls.

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

You can open the stream in both input and output modes -- just use the | or operator fstream file("text.txt", ios::in | ios::out);

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

The problem is that the toolstrip objects in Form1 are declared private. Form2 will be unable to view them without a public function in Form1 that will expose their contents or check status. Write a public method in Form1 that returns the check status of a menu item.

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

use the example code snippet I posted here, but instead of putting the line just read into a linked list copy it into that array you posted.

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

The parameters in function you posted for "what I have so far" must match exactly the parameters of the function prototype. In otherwises, the function prototype are double[], int, and int. Yours is double[], double[] and double; Not the same, one of the two is wrong.

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

Your link wants me to download and install some unknown rar file on my computer. Ain't going to happen in this lifetime. If you want us to see the instructions you were given all you hve to do in attach the text file to your post using the Advanced Editor and Manage Attachments button.

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

Homework? Have you read your textbook yet about how to declare arrays? Or this?

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

Look at the link I posted in this thread. It tells you how to code passwords

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

Walt: He said he couldn't use std::string or getline().

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

>> i also know my program donot have problem but that is something my lecturer wont agree with me. also he needs more functions

That is what I was trying to tell you in the very beginning of this thread. You have written the entire program in main(). You need to split it up so that there are several functions.

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

hahahaha now
can u tell me is it possible to calculate the number of books in the librery by suming up all the copies ?
i tried to put
int sum;
int total; ( both of them not in struct)
and open a new case
total = sum(Book.copies) but it wont work :S

It didn't work because sum is not a function. And such a function doesn't exist in either c or c++ languages. Maybe you have it confused with the sum function in SQL. The way to do it is to loop through all the books and total up the copies, very much the same way you would do it manually.

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

CLS and cls are not distinguished in C and secondly your code is error free.You do need to modify the strings section a bit.

Glad you joined in this thread, but next time please take the time to read the whole thread so that you don't look like such a fool.

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

character arrays do not have methods like c++ classes. You have to treat them as if you are writing a C program. Just call strlen() to get the length of the string. if( strlen(Book.isbn) != 4 )

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

The only way to do that is to just check the length of the string after input. If it is less than the minimum then display an error message and loop back to get new keyboard input.

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

If you know how to use linked lists you would be better off with a linked list of lines than that very huge array of strings. Something like this

struct node 
{
   struct node* next;
   char line[255];
};

Since this is c++ you could use std::vector instead of the above linked list, assuming you know how to use vectors and your teacher will allow it.

The next thing to do is NOT assume each line will contain exactly 1000 chracters. All you have to do is loop until '\n' is encountered.

int i = 0;
    char buffer[255] = {0};
    while( in.get(buffer[i]) && buffer[i] != '\n')
    {
       ++i; 
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This link has an example of how that function works. If you know how sprintf() works then you're nearly home with vsprintf(). Then if you read this thread you will see that the second parameter to vnsprintf() is the number of characters in the buffer. When compiled for UNICODE sizeof(TCHAR) will be greater than 1, the actual size will depend on the operating system you are using. MS-Windows sizeof(wchar_t) is 2, but *nix it is 4.

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

>>how can i restrict this one with 4 size
Just declare Book.published in the structure as char published[5]; There are no standard C or C++ functions that just display * for passwords. Here's a thread with some suggestions for you to think about.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
char date [10];
		_strdate_s (date);
		Book.date == date;

You can not assign c style chracter arrays like that. You have to call strcpy() to do that. But your program doesn't need to do that anyway, in the clal to _strdate_s just use Book.date instead of date variable _strdte_s(Book.date, sizeof(Book.date));

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

post new code so that we can see what you have done.

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

>>how a[0] = 1 at first

I think this is an assignment to test your understanding of addresses. Since a[0] contains the address of x, any changes to x will affect both x and (*a[0]) because they both point to the same memory location. Now, since a[6] contains the same address as a[0], and the address in a[4] is also the same as a[0], then any one of those variables are changed the new value is reflected in all three pointers.

If you printed out the values of all those address each time any one of them is changed you should see that behavior. For example, increment a[0] then inspect the value of x, a[4] and a[6]. All of them will show the same value becuse they are all pointing to the same memory location.

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

what do you think the results should be? x starts out as 1. Then a[0] is incremented the result is x = 2. a[4] is incremented and the result is x = 3; Now notice that a[6] == a[4] == a[1] == address of x. So when a[6] is incremented the result is x = 4.

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

line 31: The sizeof(a) will not give you the number of rows in the array. What you want is to use the already defined macro SZ that appers on line 3.

How to increment:
(*a)++;

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

Thanks. I just knew there must be an easier way to do that :)

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

I'm trying to find the code snippets I have posted -- it why is to do damned difficult? There used to be a link to our code snippets but its gone now. I tried advanced searched, enter my name in user id block, selected code snippets, then hit the search button. All got was a list of everyone's code snippets. I really don't want to search through hundreds of code snippets just to find the few that I've posted.

Ugggg!:@