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

Ok, I see what FirstItem refers to -- the head of the item linked list.

When I said the two functions were identical I meant the code within the functions, not the parameters. The first parameter to AddItemToClient() is just a single pointer because it is the node in the Client linked list that you want to add items to. You don't want a double pointer for this because, unlike the other function, this function will not modify it's address.

struct item* AddItemToClient(struct client *client_head, char item[])
 {
    struct item *temp = malloc(sizeof(struct item));
    temp->next = NULL;
    strcpy(temp->item_name,item);
    if( client_head->FirstItem == NULL)
        head->FirstItem = temp;
    else
    {
        struct item *t = FindTail(client_head->FirstItem);
        t->next = temp;
    }
    return temp;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

AddClient() and AddItemToClient() should both be coded similarly because they both add a new node to the tail of a linked list. The only difference is that AddClient() adds a new node to the Client linked list while AddItemToClient() adds a new node to the Client's item linked list. Otherwise both functions should be the same.

what is the purpose of FirstItem in the item struct?

line 105: you need to pass a pointer to client pointer. Your compiler should have complained about that.

AddClient(&client,name);

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

The first error is** line 95 'output_minus_10' was not declared in the scope**

Look at your program, where is that variable declared? It must be declared somewhere within the function or globally before it's used. It needs to be something like FILE* output_minus_10; or like this: FILE* output_minus_10 = fopen( "cx45_model_VH_1.dat", "w" );//Open file

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

Do you have antivirus running on all PCs? Have you checked them for malware?

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

A std::list is better suited for that purpose because vector does a lot of memory reallocations during erase while std::list does not.

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

line 64 needs to be an else statement so the the program doesn't attempt to display an erased item in the vector

    for (int i = 0; i<userDetails.size(); i++) {
        if (userDetails[i].getUserName() == name){
            userDetails.erase(userDetails.begin() + i);
        }
        else
            cout << userDetails[i].getUserName() << " " << userDetails[i].getPassword() << "\n";
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Cheating on your howmework will do you no good. Why not write the program yourself? Do the math with pencil & paper first so that you know how to solve the problem.

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

add() is wrong

void add(struct node *newp)
{
    if (head == NULL)
        head = newp;
    else {
        struct node* temp;
        for (temp = head; temp->next != NULL; temp = temp->next);
        temp->next = newp;
    }
}

Another problem here:

scanf("%s", &rep);

rep is type char, not a string. scanf() will write at least two characters to that pointer, not just one (null string terminator because %s). Change to this:

scanf("%c", &rep);

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

But it is, saying that a private var (d_lenght) in shape2D cannot be accessed because is private.

I think you misunderstood the error message. It means that Shape3D can't access private members of the base class. It's complaining about the line cin >> d_height; that appears in shape3D::set_dimensions().

Can you please be more explicit with set and get functions?

Yes, you explained it yourself perfectly, although normally they would be written as inline methods, but the way you have them is ok too.

class a
{
    public:
        a();
        virtual ~a();
        void set_value(int x) {y=x;}
        int get_value() {return y;}
    private:
        int y;
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It doesn't really matter where you put the space in the syntax, the compiler doesn't care. The examples you posted are all acceptable and correct. It's only a matter of programming style -- however you wish to do it.

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

I don't understand why it works with private vars if I don't modify the methods and why should I use protected in the other case.

private: means the derived class cannot access the variable -- if the defived class doesn't attempt to access the private member then there is no problem or error. There's a couple ways you can handle that.

  • Change the variables from private to protected
  • In the base class add get and set functions
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Then you did something wrong. This works perfectly

#include<iostream>
#include<cstring>
using namespace std;
#pragma warning(disable: 4996)

int main()
{
    int vowelcounter = 0;
    char * tokenPtr;
    char myarray [] = "My name is Faraz Saleem Rafai";
    char check [] = "aeiou";
    int length = 0;
    int origlength = strlen(myarray);
    // display all the vowels.  Your program doesn't need this part, 
    // it's here only to verif the results are right or wrong.
    for (int i = 0; myarray[i] != 0; i++)
    {
        myarray[i] = tolower(myarray[i]);
        if (strchr(check, myarray[i]) )
            cout << myarray[i];
    }
    cout << '\n';

    tokenPtr = strtok(myarray, check);
    while (tokenPtr != NULL)
    {
        length += strlen(tokenPtr);
        tokenPtr = strtok(NULL, check);
    }
    cout << "orig length: " << origlength << " numvowels = " << origlength - length << '\n';
    return 0;



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

Could you explain me why in every function you use something like: struct item*

Yes, because that parameter is the head of the linked list to be used. How else do you think those functions are going to know where the top of the linked list is, and which linked list the function is supposed to use?

what does it change, and is there need for strcpy function in AddItem

AddItem creages a new node of type struct item, copies the value of item_name into the structure, and finally inserts the new node at the tail end of the linked list.

as I'm not that familiar with it.

You should already be familiar with strcpy() function, its one of the very basic string functions you learn. Since you are studying linked lists you most likely have already learned about strcpy(). If not, look it up in your textbook or google for it online.

Also would like to know why in function AddItem there's struct item** head while function FindTail has struct item* head .

Because AddItem() is going to change the caller's linked list, while the other functions such as FindTail() does not. The only way AddItem can change the value of the pointer passed by the calling function is to pass a pointer to the original pointer. I know, pointers can get confusing, but that will become clearer after you study and test it yourself.

Your thoughts at the end of …

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

seems like normal linked list for me.

Yes -- what you want is just two nested normal linked lists.

Once you understand simple linked list it is just slightly more complicated to do nested linked lists. I would do it like this: The last function AddItem() shows how to allocate memory for the item linked list.

    struct item{
    char item_name[30];
    struct item *next;
    }

struct client{
    char name[30];
    char last_name[30];
    struct item *d;
    struct client *next;
}


struct client* FindClient(struct client* head, const char* name)
{
    while(head->next != NULL)
    {
        if( strcmp(head->name,name) == 0)
        {
          return head;
        }
        head = head->next;
    }
    return NULL;
}


struct item* FindItem(struct item* head, const char* item_name)
{
    while(head->next != NULL)
    {
        if( strcmp(head->item_name,item_named) == 0)
            return head;
    }
    return NULL;
}

struct item* FindTail(struct item* head)
{
    while( head->next != NULL)
       head = head->next;
    return head;    
}

struct item* AddItem(struct item** head, const char* item_name)
{
    struct item* newnode = malloc(sizeof(struct item));
    newnode->next = NULL;
    strcpy(newnode->item_name,item_name);
    if( *head == NULL)
    {
        *head = newnode;        
    }
    else
    {
        strict item* node = FindTail(*head);
        node->next = newnode;
    }
    return newnode;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Were those two structures given to you or can you make them up yourself?

There are two linked lists -- Client and within each client node is a Items linked list.

To add a new client node you have to search the Client linked list to see if it is already there. If not, then add a new Client node to the end of the Client linked list.

To add a new Items node to a Client node, first find the Client node, as above. Once found, search it's Items linked list to make sure there isn't already an Items node in the list. If not, then add a new Items node to the tail of the Items linked list.

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

strtok() cannot be used the way you are trying to do it, you can't use it to count the repeating adjacent vowels because of the way strtok() works.

To determine the beginning and the end of a token, the function first scans from the starting location for the first character not contained in delimiters (which becomes the beginning of the token). And then scans starting from this beginning of the token for the first character contained in delimiters, which becomes the end of the token.

What you might do is to count all the characters in the strings returned by strtok(), then subtract that from the length of the string. The remainder is the number of vowels in the string. So, instead of counting vowels you need to count non-vowels.

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

char check[]="'a','e','i','o','u'";

That does not produce a null-terminated string, which strtok() requires. Just do this:
char check[] = "aeiou";

But --- Deceptikon has a better solutiom.

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

Visual Studio want angle brackets, not quotes, around the names of standard c++ and VS header files

#include <iostream>

void main

it's int main(), never void main() because main() always returns an integer back to the operating system.

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

The IDE should have told you what those error numbers mean and on which line they occur. We can't tell you much about them unless you post the complete code. google for the error numbers and you will find more detailed information about the errors.

If you don't turn off precompiled headers stdafx.h must be the first include in the program -- no other includes can appear before that one. With precompiled headers option turned on you MUST includer stdafx.h, you can't delete it or the compiler will error out. The option to turn precompiled headers on or off is given when you first create the project, but you can do this later after the project has been created if you want to.

How to turn off precompiled headers
In VS++ 2013, select menu Project --> Properties (last item in the list)
Expand Configuration Properties tab
Expand C/C++ tab
Select Precompiled Headers
on the right side of the window select the first item, Precompiled Header and change it's option to Not Using Precompiled Headers

901557570341da0634fcdb0ac5c8ee5e

Also, if you don't turn off UNICODE then the compiler will assume you want to use UNICODE style strings, instead of char* you will have to use wchar_t*. This affects both string literals and character arrays. If you are not interested in languages other than English, then I suggest you turn off UNICODE, especially when first learning programming.

How to turn UNICODE off

In VS++ 2013, …

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

The limit only applies to old 16-bit compilers, and I think the compiler you installed is like that. Why don't you install either Code::Blocks with MinGW compiler or Visual Studio 2013 Express (both are free).

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

What new compiler did you install? Visual Studio will compile both 32 and 64 bit programs, its just an option change. The compiler itself is a 32 bit compiler and is always installed in the Program Files (x86) folder.

Is your entire program contained within just one *.cpp file? If you still want to use those old 16-bit compilers then try splitting the program into more than one file -- Turbo C++ probably attempts to put everything in the same *.cpp file into the same segment, depending on the memory model used. If you use the large or huge memory models then you can have bigger programs, assuming the program consists of two or more *.cpp files.

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

Many studies (such as this one) over the years have tied life expectancy to economic status. Whether availability of heal insurance has anything to do with it, I don't know. But I would expect it to have some influence. Example: I probably would have died about 8 years ago had it not been for my health insurance paying for heart doctor putting stints in my heart. Someone without heart insurance probably would have just died.

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

Yes, someone has to pay for it sometime -- the docctors, nurses, hospital staff, etc don't all work for free, they have to make a living too otherwise they'd do something else such as digging ditches. I've heard for years that the top dollar-makers leave the UK because if high taxes.

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

Ooooh I would kill for a Krispy Kreme.

I never liked them -- they always tasted greasy to me. My favorite donut is cake donut with coconut frosting.

They have closed down many of them because a lot of schools banned them because they make the kids fat which decreased their sales ;

Yeeaahhhoooooo! There's one near me but I've only been there once in the past 20 years.

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

jelly filled sugar cookies

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

VB Users, always include "stdafx.h"

Why?? It's only necessary if you use Visual C++ and then only if you use precompiled headers option. Otherwise you can delete it.

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

I prefer dereferencing using -> because it's simpler and doesn't make me think about it. Similar to a native English speaking person reading code written in English instead of some other language that has to be translated into English. Both might do the same thing, but one is more easily read than the other. And that's one of the big purposes you want to achieve with the code you write -- make it understandable, not cute.

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

Here is a more complete and compilable program snippet

#include <string>
#include <iostream>

int main(int arc, char* argv[])
{
   std::string input;
   if( argc > 1)
      input = argv[1]; // get string from command-line argument
   else
       std::cin >> input; // get string from keyboard or from stdin
}

argc is the number of command-line arguments plus the name of the program. On most platforms the value of argc is at least 1. argv is an array of strings that represent each of the command line arguments. argv[0] is the name of the program.

So, if the name of the program is myprog.exe and you execute it like this on the command line
myprog one two three

The value of argc will be 4.
argv[0] == "myprog.exe" (sometimes it includes the full path)
argv[1] == "one"
argv[2] == "two"
argv[3] == "three"

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

I don't know a thing about it, but according to wiki there is only one king of the Belgiums (Philippe).

at the moment we have two kings and three queens!

Oh, I didn't know they were Mormons :)

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

Well, let's get back to X-mas. So J.C. was born 25 december of the year 0, right?

No, he was most likely born in the spring because shephards don't herd their sheep in the middle of winter. The three kings didn't see Jesus in the manger either -- it probably took the three kings several years before they saw him. Afterall, you can't walk or ride a camel across the desert over night. Well, maybe you could if you had a really really fast camel. Also, there is no mention where those three kings came from. Three kings all from the same country -- doubtful.

Matthew says only that these visitors came from "the east." Scholars have speculated that they came from Persia, Arabia, or even India.

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

I'm not sure what you want. Something like this???

int main(int arc, char* argv[])
{
   std::string input;
   if( argc > 1)
      input = argv[1]; // get string from command-line argument
   else
       cin >> input; // get string from keyboard or from stdin
}

cin does not allow space in the string, so if you need the spaces you can not use cin with >>, but call getline() instead of cin

assiming input is of type std::string
getline(cin,input);

when input is char array and not a pointer

char input[80];
cin.getline(input, sizeof(input));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Being an atheist back then was tantamount to signing your own death warrant,

Yes, you have a good point :)

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

I don't mean to deny anyone from using the Gregorian calendar -- it's just seems a little odd we didn't standardize on the Hebrew or Chinese calendar instead, and I'm sure there probably have been many other calendard around the different nations on earth.

Why should the Chinese calendar be a better option?

Because AFAIK it is not based on any religion.

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

I'm in NYC and us jews use the hebrew calendar, so yes. :

According to that wiki article, even the Hebrew calendar has some reference to the birth of Christ

Until the Tannaitic period (approximately 10–220 CE)

CE -- Common Era or Christian Era

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

Christians usually think they're better than everybody else and thus deserve special priviledges

Not at all -- I just find it rather funny that the entire world has adopted the Christian calendar. Why not adopt the Chinese calendar? It just goes to show that the birth of Christ was one of the most significant and important events in world history. No other person, living or dead, has had more influence on the history of the world.

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

yea, I enjoy stirring the pot occasionally to see what falls out. :)

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

Funny, all you athiests out there so willingly use the Gregorian calendar, which is based on Christian holidays (Easter, Christmas and the birth of Christ). If you don't believe in God then why use the Gregorian calendar? Why not the Chinese or some other calendar? Even the year 2013 means 2,013 years since the birth of Christ (which is just a guess).

The term Anno Domini is Medieval Latin, translated as In the year of the Lord,[1] and as in the year of Our Lord.[2][3]:782 It is sometimes specified more fully as Anno Domini Nostri Iesu (Jesu) Christi ("In the Year of Our Lord Jesus Christ").

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

Youtube version of that song

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

12 days of Christmas song -- how many people were given to my true love? No fair peeking or googling.

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

So is the Easter Bunny :)

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

According to wiki that isn't exactly true

Images of Santa Claus were further popularized through Haddon Sundblom’s depiction of him for The Coca-Cola Company’s Christmas advertising in the 1930s.[7][32] The popularity of the image spawned urban legends that Santa Claus was invented by The Coca-Cola Company or that Santa wears red and white because they are the colors used to promote the Coca-Cola brand.[33] Historically, Coca-Cola was not the first soft drink company to utilize the modern image of Santa Claus in its advertising—White Rock Beverages had already used a red and white Santa to sell mineral water in 1915 and then in advertisements for its ginger ale in 1923.[34][35][36] Earlier still, Santa Claus had appeared dressed in red and white and essentially in his current form on several covers of Puck magazine in the first few years of the 20th century.[37]

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

hence in Scotland we tend to go all out in celebration at Hogmanay (party starts on 31st and lasts until the 1st or 2nd).

LOL -- I'm moving to Scotland :)

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

clearly, Christmas is simply not tied to a religion, and thus, the state can have this federal holyday without violating church-state

That's not true here in USA. Here, Christmas is all about celebrating the birth of Christ, probably 75% of all Christmas music has Christ as it's theme.

Christians claim Christmas for themselves

It's called CHRISTmas for a reason. Name it something else if you don't think the holiday is all about Jesus Christ.

Happy Holidays is as good as any.

just like they claim marriage for themselves

Christians aren't the only ones -- I heard just the other day that India made gay sex/marriage illegal. It's also banned in other countries, like Russia.

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

seems like im the only one with the error 2816

Or you are one of the few people still using Dev-C++, which hasn't been updated in many years. If you want to use MinGW then Code::Blocks is a lot better IDE than Dev-C++.

centenond commented: Code::Blocks works fine! thanks! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In fact I think America should just make every religous day, from every religion, a federal holiday.

A friend of mine is from India and he says they have lots of holidays -- maybe you should move to India. As for me, I never liked holidays, too boring, I'd rather work.

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

No one said anything about abolishing Christmas, just abolishing the American federal holiday. Nothing else would change.

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

here is a related thread. If you google for "error 2816" you will find similar related articles.

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

Most people already know that Christ was not born Dec 25th, but most likely in the spring. But the very name CHRISTmas is to celebrate the birth of Christ. One of the early Pope's decided Dec 25th would be as good a date as any to celebrate since that date is already celebrated for other things.

Many people suffer from the misconception that Christmas is a Christian holiday

Well, it wouldn't be called Christmas if it wasn't a Christian holiday. Why not just name it "Winter Festivals" or something like that?