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

Read the first sentence I wrote

Compare the parameter list of the function on line 18 with what you are trying to do on line 107. The number of parameters on line 107 must be the same as on line 18, and of the same data types.

The function takes 3 parameters, not just one. Or is there another version of that same function that you have not posted which takes only one parameter?

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

I told you about 21 hours ago what's wrong, there is no function named getFine() that has only one parameter, or at least you didn't post one.

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

SOCKET shold be an int, not char because it's value can be a lot larger than what an char can hold.

The file that contains SOCKET declaration is probably not reachable to the *.c file or there could be an #ifdef around it.

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

The function doesn't make much sense. For example, line 15 is unreachable, If line 5 is false then the only other option is for line 8 to be true. This is a simplified version of your function

   int find_index(int num,int Niz[],int index){



       if(num == Niz[index])
        return index;

       find_index(num,Niz,index++);

       return -1;

   }

Besides that, that happens when num is not in the array at all? The recursion continues infinitely because there is nothing to stop it and the value of index keeps incrementing forever.

A simple loop would be a lot more efficient for this purpose than recursion.

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

Compare the parameter list of the function on line 18 with what you are trying to do on line 107. The number of parameters on line 107 must be the same as on line 18, and of the same data types.

line 18: why is totalFine a parameter to the function? Isn't totalFine what that function is supposed to calculate? It would make more sense if the function parameters were like this:

int getFine(int speedingType, int speedLimit, int vehicleSpeed)
{
   int totalFine = 0;
   ...
   ...
}   

Also, the if statements on lines 22, 30 and 38 are incorrect. Use == operator, not the = assignment operator. That would actually be better as a switch statement.

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

Did you write GetFloat()? Post it's source code so that we don't have to guess what it does.

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

To do it in either C or C++ you need to read some tutorials about socket programming. There is a difference between MS-Windows and *nix sockets, so you first have to determine which platform you are writing for. Here are some google links that you might find helpful.

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

Because after you enter a number from the keyboard you have to press the <Return> or <Enter> key. That key, '\n' remains in the kayboard buffer until the next input is made. In the case of another number, cin skips all leading whitespace characters (space, newline, tab, and backspace) then process the remaining keys up to the first non-numeric digit. But, in the case of character array cin starts with the first character it finds in the keyboard buffer (which is now '\n') and stops when it finds end-of-data or a newline. Since the newline is the first character in the buffer cin won't do anything.

The way to solve that problem is to clear the keyboard buffer before calling cin. There is a thread here that explains how to do that in great detail.

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

I have both windows 8.1 and windows 7 on the same homegroup network and they each share printers and folders with each other. Most are wired, but one is wifi.

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

the value of SIzE is 4, the initial value of counter is 0. So SIZE never equals (counter+1). The value of counter never changes inside the loop.

how is the right way to do it?

Increment counter somewhere inside the loop but outside the if statement, most likely place is on line 4.

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

It looks like main() is calling the wrong function. insertIntoTable() instead of insertValuel()

IMO insertValue() is too complicated, paramitizing the sql like that is not necessary.

sprintf(sql,"INSERT INTO table(id,text) VALUES(%d,\"%s\")",1,randomText.c_str());

Now with that simple line call sqlite3_exec(), as shown in this 5-minute tutorial.

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

person.name[i]

You need to index person, not name

person[i].name

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

line 11: remove all the spaces.

haider885 commented: thanks....its working now +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No, I will not solve it for you, but we will help you solve it yourself. Post some code that you have started so we can see where you need help.

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

It runs in the curreent thread.

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

I did this and it still works ok

    char* result;
    while( (result = fgets(line, sizeof(line), fp)) != NULL)
    {
        puts(result);
        char* token = strtok(line, " ");
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can usually find online help with most c++ functions and classes by googlein for them. In this case, google for "c++ std::string" and this will be the first hit you see.

Once there, click the link (constructor)

Next, look down the page at Parameters and you will find this (where n is the first parameter and c is the second):

n
Number of characters to copy.
c
Character to fill the string with. Each of the n characters in the string will be initialized to a copy of this value.

In otherwords, line 14 is creating a std::string object of 1 character and initializing it with whatever *being points to.

lines 19-22 loops through the rest of begin, but to me that loop isn't doing much of anything. I don't see any purpose of that loop.

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

Nothing wrong with fgets()

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma warning(disable: 4996)

int main()
{
    char line[126];
    FILE* fp = fopen("TextFile.txt","r");
    if (fp == NULL)
    {
        puts("Can't open the file");
        return 1;
    }
    while( fgets(line, sizeof(line), fp) != NULL)
    {
        char* token = strtok(line, " ");
        if( strcmp(token,"Client:") == 0)
        {
            puts("CLIENT");
            while (token != NULL)
            {
                puts(token);
                token = strtok(NULL, " ");
            }
         }
    }

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

You must be doing something else wrong. This works ok for me

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma warning(disable: 4996)

int main()
{
    char line [] = "Client: z q";
    char* token = strtok(line, " ");
    if( strcmp(token,"Client:") == 0)
    {
        puts("CLIENT");
        while (token != NULL)
        {
            puts(token);
            token = strtok(NULL, " ");
        }
    }

}

And the console display is this:

CLIENT
Client:
z
q
Press any key to continue . . .

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

post the line that was read from the file. If the program doesn't print "CLIENT" like you had on line 16 then my guess is the line in the file doesn't contain the word "Client" at the beginning -- remember capitalization is important, so Client and client and client: are not the same.

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

line 17 the first parameter to strtok() should be NULL, because it's alredy been called with line as the first parameter on line 12.

if( strcmp(token,"Client:") == 0)
{
    printf("CLIENT\n");
    token = strtok(NULL, " ");
    while (token != NULL) {
        puts(token);
        token = strtok(NULL, " ");
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, it works something like that. Example:

char line[] = "one two three 123 456";

char* ptr = strtok(line," ")
while( ptr != NULL)
{
   puts(ptr);
   ptr = strtok(NULL," ");
}

The first time strtok is called with a charater array. After that, the first parameter to strtok() is NULL. It will return NULL then the last token has been read, normally meaning end-of-data.

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

This is one way to do it.

fgets(line,sizeof(line),fp);
// get first token on the line
char* token = strtok(line," ");
if( strcmp(token,"Client:") == 0)
{
   // process line as client
   // call strtok() in a loop to extract the other tokens

}
else
{
    // process line as item
   // call strtok() in a loop to extract the other tokens
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Read a line. If it starts with Client then you know you have to allocate a new client node. If it starts with Item then add a new Item node to the most recent Client node.

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

There are many ways to accomplish it. You could add a small item at the beginning of each line that identifies it as either client or item.

 fprintf(f,"Client: %s %s\n",head->client_name,head->client_last_name);

 fprintf(f,"Item:  %s %s %f %s %f ",CurrentItem->item_name,CurrentItem->item_state,CurrentItem->item_price,CurrentItem->item_status,CurrentItem->item_price_if_not);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It doesn't work because it never saves the data to the file.

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

Do you mean the sum of each column? You will need two loops to do that, the outer loops counts N columns and the inner loop counts M rows. It's almost identical to the way you would do it on paper or in an Excel spreadsheet.

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

line 15 of the code you posted is wring.

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

Other than poor formating, I don't see anything wrong with how you allocated the array. The values in the array are something else.

void John_is_3D(int dimx, int dimy, int dimz)
{

    int ***John; // pointer to pointer to pointer
    John = new int**[dimx]; // array of pointers to pointers


    for (int x = 0; x<dimx; x++)
    {
        John[x] = new int*[dimy];
        for (int y = 0; y<dimy; dimz++)
        {
            John[x][y] = new int[dimz];
            for (int z = 0; z<dimz; z++)
            {
                John[x][y][z] = x*y*z;
                cout << John[x][y][z];

            }

        }
        cout << endl;
    }



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

line 18: since the node is now deleted you might as well stop looking, unless there could be more nodes with the same name.

lines 20 and 21 won't work because current has already been deleted on line 18.

current = prev->next;

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

a+b adds the two ascii values. Look at any ascii table and you will see that 'a' == 97 and 'b' == 98, so a+b = 97+98 = 195. Now look again at that ascii table and find the character whose ascii value is 195.

What you want to do is to save them in an array of characters

char array[3]; // room for 2 characters
array[0] = 'a';
array[1] = 'b';
array[2] = '\0'; // string null-terminator

cout << array << '\n';

[edit] What ^^^ he said too :)

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

It's pretty simple, exactly like deleting the client node from the linked list. The item list is just like the client list.

If current is the node to delete, then

set prev-next = current->next
delete current

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

You shouldn't have to allocate any new memory -- it's alredy there, just overwrite the fields of the pointer that FindToAdd() returns. I'd also change the name of that function to just Find() so that it better describes its purpose. Once found, just copy the new information into the client structure.

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

That looks right, if the intent is to delete the entire client list.

To do edits you don't need to delete anything. Just search for the client you want then change the value of the client's properties. Of course you will have to get the new values from somewhere, most likely just prompt for them and get keyboard input, very much like when the program got the original client values.

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

To delete the inner list just iterate through the list and delete each node one at a time, something like this: It assumes head->item_data pointer is NOT NULL, so you should probably test for that before executing any of the code in this function.

void DeleItemList(struct client* head)
{
   struct item* save;
   struct item* it = head->item_data;
   while(it->next)
   {
      save = it;
      it = it->next;
      free(save);
   }
   head->item_data = NULL;
 }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Function AddClient() doesn't return anything. Either make it return something or make it a void function. Try this, where I've remove redundent code.

Try this version, where I removed redundent code.

void AddItemToClient(struct client *head, char item_name[30], char item_state[30], double price, char status[30], double price_if_not, int day, int month, int year)
{
    struct item* it = malloc(sizeof(struct item));
    strcpy(it->item_name, item_name);
    strcpy(it->item_state, item_state);
    strcpy(it->item_status, status);
    it->item_price = price;
    it->item_price_if_not = price_if_not;
    it->issue_date = malloc(sizeof(struct date));
    it->issue_date->day = day;
    it->issue_date->month = month;
    it->issue_date->year = year;
    it->next = NULL;
    it->issue_date->next = NULL;

    if (head->item_data == NULL)
    {
        head->item_data = it;
    }
    else
    {
        struct item* node = head->item_data;
        while (node->next) node = node->next;

        node->next = it;
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is there any reason I should rename it to eulerTwo?

You can, but it's not necessary. There is nothing wrong with using numbers in function names -- it's actually pretty commen.

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

You can also do it with _stat()

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

@mike so simply by using static in every function we mean that we want this variable to be related to the function only

No -- variables declared within a function are never visible to other functions, and they are auto destroyed as soon as the function returns to it's caller. Making variables within function static means that the variable will hold it's value from one function call to another, they are not destroyed when the function returns like non-static variables. You can easily prove this to yourself by running the following program

int foo()
{
   static int x = 0;
   cout << x << '\n';
   ++x;
}

int main()
{
   for(int i = 0; i < 10; i++)
      foo();
}

Now, run the same program again but this time remove the static keyword. You will see the value of x is always 0.

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

You are using way to many unnecessary parentheses and duplicate code For example dodaj() can be simplified like below, where the allocation is only done once at the beginning of the function. No need to repeat the lines within the function.

void dodaj(lista **l, int n, char tab[])
{
    lista* newnode = (lista*) malloc(sizeof(lista));
    newnode->liczba = n;
    newnode->data = NULL;
    strcpy(newnode->napis, tab);
    newnode->next = NULL;
    if (*l == NULL)
    {
        *l = newnode;
    }
    else
    {
        lista *pom = *l;

        while (pom->next) pom = pom->next;

        pom->next = newnode;
    }
}

Since your program is not in English I have no idea what those function names mean -- they are just meaningless to me. For example what is dodajmiejsce() supposed to do?

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

I wouldn't use strtok(), just modify the code previously posted to keep track of the position of each vowel, the loop's i counter is the location within the string. Now all you have to do is add some arrays to save that value.

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

You will probably have to use two arrays, one array for the letter and within that an array of each location number. Something like this.

struct location
{
   char letter;
   vector<int> locationNumber;
};

vector<location> locations_array;

The above assumes you have studied std::vector in your class. If not, then maybe you can use linked lists instead of vector.

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

That's a microsoft compiler thing -- it supressed warning number 4996, which is a warning about deprecated functions. Just delete that line if you use another compiler.

how can we cout the locations

What do you mean by "locatins"? The vowel's position within the string? Such as there is an "a" in the 5th position of the string?

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

First you have to create a project, that will generae a default *.cpp file. You can put your class there or add a *.h file to the project. You might want to read Getting Started page here.

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

I got the same results when I tried it after I posted that reply.

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

<deleted>

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

Not that I know of, but you can get the text itself. The size of the rectangle would depend on the font being used.

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

don't you know how to use google?

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

Isn't that all explained in your textbook?