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

line 6 is ok as it is. Changing it to **prog_arv would make lines 10-13 errors because of unallocated memory for those pointers.

you need to remove * to have char prog_arv[4];

No, lines 10-13 won't compile if changed like that.

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

Please write in full English words -- this isn't a chatroom. There are a lot of non-native English speaking people here who have no idea what you just wrote. Finally, not much point posting an executable -- most people won't bother to intall it on their computer for fear that it may contain virus or malware.

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

wrote a program to display the numbers 1 through 100 on the console window.

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

Stopped snowing last night, the show plows where out in our neighborhood about 10:00 pm shoveling the snow from the street up into our yards. Nice clear day this morning, we have not seen this much snow in 30 years. Temp isn't as bad as they thought it would be either, only about 1F.

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

It doesn't work through web (

It worked ok for me the first time I tried it with my PCs Chrome browser. Maybe google mail is just wierd :)

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

Do the requirements one at a time, don't attempt to code it all at once. First, code the menu, comple, fix any errors, and repeat until it works correctly. Then you are ready to code the next requirement, repeating the same steps you did for the menu. In the meantime you are free (encouraged) to post code and ask questions about what you don't understand or how to fix something that doesn't work right.

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

And also I think there is a way to read the file size,

That won't produce the file size, just the number of integers in the file. The integer "123" is at least three bytes in the file (could be more), not one.

From the first sentence> was writing a program that opens a file assigns each element to an array.

Yes, you are right, I was wrong about that, didn't read the first sentence good enough.

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

I think you heard wrong (click me)

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

Well, maybe I didn't. In any event, it's identical to the others.

33 + (rand() % 15)

15 because there are 15 different symbols that appear in consecutive sequence in the ascii table. Unfortunately, there are a few others that too which can't be accessed this way. If you want to use them too then it might be better to create an array of symbols an access them using the formula (you did that in your original post).

 char symbol[] = {'!', '£', '$', '€', '%', '^', '&', '*', '(', ')', '@', '#', '<', '>', '?', '+', '=', '-'};

 char c = symbol[sizeof(symbol) + (rand() % sizeof(symbol))];
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

yes, I already posted an example of it.

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

I'll bet there aren't very many birds flying around either :)

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

If your goal is to find out how many numbers are in the file then you can't use the method I suggested. But if you want to file out the entire file size, such as what you see with Mcirosoft's File Explorer, when the way I suggested is how to go about doing that.

First of all try to use vector and to add the new members at the end of vector.

Vectors are useless for this purpose unless you need to use the data for something else.

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

MSSQL is no longer the behemoth it used to be and is actually very fast now.

I was referring to SQL-compliant databases in general, not a specific one.

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

Delete those line, they are not valid c or c++.

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

Is it possible to get <myname>.daniweb account?

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

you should call srand() at the beginning of main() so that rand() will return a different set of random numbers each time your program runs.

srand( (unsigned) time(0) );

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

It's snowing heavily here today, started last night. There is about 6 inches on the ground and still snowing. Temp is good though, only 23F.

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

I hope its an acceptable way of doing it.

Yes, you have exactly the correct approach.

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

what about storing data in a txt file with our own rules?

SQL is not the only kind of database -- in fact SQL can be very very slow when tables are large and using complex queries. Quite a few years ago I used Raima Database Manager, which, at that time, was not SQL. The advantage of RDM was that relationships were hardcoded at design time, so queries were very fast, several times faster than SQL databases. We didn't have huge multi-gigabyte files in those days so I don't know how it would perform in that situation.

You might want to do some evaluation yourself on what is better to use in your application -- you might be able to get fee evaluation version of RDM and an SQL database to test how they compare with plain-old-text files.

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

Can someone please rectify the mistakes in the following code?

What specific problems?

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

Why would you even want a cracked version when you can get it free (Express version) from Microsoft?

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

'1' - '9' + 1)

Wrong -- that will produce a negative number

c = '0' + rand() % ('9' - '0' + 1);

You're missing requirement to generate at least 2 symbols.

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

Test reply.

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

what compiler are you using, and what version of windows?

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

Oh, I didn't realize there were two threads with the same title. But it appears to have worked ok when replying from desktop.

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

why this erorr?

What error?

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

>

This is reply from desktop Thunderbird client.

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

You used it on line 5 of your original post so I thought it was already declared somewhere. If not, then pass it as a parameter to the funciton

struct dict_word
{
    char orig_string[100];
    char word[40];
    char definition[100];
    int year;
    char eng_synonyms[100];
    char heb_synonyms[100];
    struct dict_word* next;
    struct dict_word* previous;
};

void insert_beginning(struct dict_word** head, struct dict_word** last, char words[100])
{
    struct dict_word* word = malloc(sizeof(struct dict_word));
    strcpy(word->orig_string, words);
    strcpy(word->word, strtok(words, "_#_"));
    word->year = atoi(strtok(NULL, "_#_"));
    strcpy(word->definition, strtok(NULL, "_#_"));
    strcpy(word->eng_synonyms, strtok(NULL, "_#_")); // this line may be wrong
    if (*head == NULL)
    {
        *head = word;
        (*head)->previous = NULL;
        (*head)->next = NULL;
        *last = *head;
    }
    else
    {
        word->next = *head;
        (*head)->previous = word;
        word->previous = NULL;
        *head = word;
    }

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

it complain during compilation.

Post error message and line numbers where the errors occur.

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

Is this the same program you posted in the C forum?

It tells me "Ordered comparison between pointer to integer (char to int)"

Which line does that error message belong to? Your compiler should have given you the line number.

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

As you read each line of the file create a node of dict_word and fill in the struct with the information from the line. After that you can add the new node to the head of the linked list.

 struct dict_word
 {
    char orig_string[100];
    char word[40];
    char definition[100];
    int year;
    char eng_synonyms[100];
    char heb_synonyms[100];
 };

 void insert_beginning(char words[100])
 {
    struct dict_word* word = malloc(sizeof(strucgt dict_word));
    strcpy(word->orig_string,words);
    strcpy(word->word,strtok(words, "_#_"));
    word->year=atoi(strtok(NULL, "_#_"));
    strcpy(word->definition, strtok(NULL,"_#_"));
    strcpy(word->eng_synonyms,strtok(NULL,"_#_")); // this line may be wrong
    if (head==NULL)
    {
        head=word;
        head->previous=NULL;
        head->next=NULL;
        last=head;
    }
    else
    {
         word->next = head;
         head->previous = word;
         word->previous = NULL;
         head = word;
    }

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

first call seekg() to move the file pointer to the end of the file, then call ftell() to get the file size, allocate a buffer of that size or larger, call seekg() again to move the file pointer back to the beginning of the file, then call fread() to read the entire file into the buffer at one time.

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

Yes, Dani I think you are right.

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

I'm now a little confused about what it is that you need help with. Do you need help reading the strings from the file, separating them, saving individual parts in the structure? Or do you need help in searching the linked list?

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

I read somewhere that you need to learn Objective C in order to write games/programs on MAC. I know nothing more than that about it, so I can't answer any of your questions about it. And review these google links.

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

I saw a sci-fi movie once where people were sacrificed to the gods on their 25th birthday (they were considered too old after that I suppose).

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

(word)#(year)#(definition)#(diff synonyms)

Huh? Why would you want to input that string??? It would be helpful if you posted the actual text of the first couple lines of the file.

i'll need to search for a definition and get the word

What do you do with multiple words that have the same definition?

I would add definition to the structure so that you don't have to search the original string each time you want to use it.

 struct dict_word
 {
char words[100];
char definition[100];
int year[10];
char eng_synonyms[100];
char heb_synonyms[100];
 };

Now just split the original string only once, immediately after it's read from the file.

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

int ch = 33 + (rand() % 126)

I posted this 2 days ago! Look at any ascii table, such as this one. You should know that an unsigned char holds values from 0 to 255, that table shows you each one of them. The decimal value of the letter 'A' is 65, while the decimal value of 'a' is 97. We use that information in the formula. rand() % <some number> produces an integer between 0 and <some number>. All we need from the ascii table are some of the values between 0 and 126, the others we can ignore because they are not needed in your program. Now, we really don't want any of the values between 0 and 32 either because none of them are printable, so all we have to do is add 33 to the value returned by rand() % <some number>

The formula now gives you random numbers for all printable characters. But that isn't exactly what you want either. Your instructions say to generate at least two upper case letters. To do that all we have to do is modify the formula slightly. The English alphabet has 26 upper-case letters (not counting numbers). The ascii chart says the value of the first upper case letter is 65. So we need to modify the formula like this:

int ch = 'A' + (rand() % 26)

The second instruction says you have to generate at least 2 lower-case letters. Now the …

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

Before buying any book read the reviews at amazon.com -- they might save you some money by not buying a useless book.

For example:

You are looking at the most expensive book on C++ ever written, with nothing magical to show for that $110+ price [edit: with the fall semester underway, the price is now $135+].

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

Sometimes it's better to just start all over (I've done that before too). Create a new program and code what I said before. Forget about the menu for now, just get the code working that uses rand() to generate a single character using the forumla I previously posted.

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

But if things are really moving to the "cloud"

From what I can see, "cloud computing" is nothing more than distributed computing over the internet. Several programs, such as Folding @ Home, have been doing that over 10+ yerars now.

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

It helps a lot if you learn to use your compiler's debugger, assuming it has one. If yours doesn't, then get a different compiler because yours is pretty useless in today's world of programming.

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

First, write a function that generates a random number between two values. The two values should be parameters to the two function. For example, if you need to generate a random number between 'a' and 'z', then it should generate one of 26 numbers starting with 'a'.

char GenerateNumber(char start, int quantity)
{

}

I already gave you the formula that generates the random number, just replace the hard-coded values in the forumla I posted with the two parameters to this function and you're done.

After than, main() just needs to call that function twice to get two random numbers between 'a' and 'z', twice more to get characters between 'A' and 'Z', and twice again for '0' to '9'.

char a = GenerateNumber('a',26);
char b = GenerateNumber('A',26);
char c = GenerateNumber('0',10);

The dictionary file is a .txt file that keeps a record of all the used passwords.

That's a password file, not a dictionary file. A dictionary file contains a list of words and possibly their definitions.

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

I don't consider it a fault of the universities for cranking out too many Ph.D.s, but for mankind in general. I don't know, but I suspect the number of Ph.D.s per 100000 population has remained fairly constant for the past hundred years. The planet just has too many people. We need to drop a few nuclear bombs here and there to de-people the planet.

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

Probably because the lone ranger was a wimp (Eastern lawyer), the movie was more about tonto than it was the lone ranger and was a comedy, not drama. Don Knotts would have been just as good, maybe better, in that part had he been alive.

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

Or you could just write your own clrscr() function, it's not all that difficult, just a one line function.

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

The use of also is ok, but it should refer to something that was previously said. Since it doesn't, then also should have been omitted.

ddanbe commented: Thanks AD :) +0