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

You can never skip parameters in C language -- they are always required. In this case num is the maximum number of characters that can be put into the buffer. If the newline is encountered in the file before that then the newline will appear in the buffer. If the newline does not appear in the file then the buffer will not contain a newline.

How are A, B, and C declared? You really don't even need them, just reuse buffer

Are those lines really 1,000,000 characters??? What's a whapping big line. Reduce the size of buf to a more reasonable number.

            FILE *ptr_file;
            char buf[256];

            ptr_file =fopen(filename,"r");
            fgets(buf, sizeof(buf), ptr_file);
            fgets(buf, sizeof(buf), ptr_file);
            fgets(buf, sizeof(buf), ptr_file);
fscanf(ptr_file,"%s %f %s %f %s %f %s %f %s %f %s %f %s %f %s",Date1,&Load1,QCLoad,&Tamb1,QCTamb,&TOT1,QCTOT,&WindA1,QCWindA1,&WindB1,QCWindB1,&WindC1,QCWindC1,&Tamb2,QCTamb2);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here, two common mispronunciations around here are:

"Missouri" a state name, pronounced missourah or missouree, even state officials such as the Governor and state federal senators flip flop between the two pronunciations.

and Des Moines (the capital of Iowa) where the s is silent.

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

fgets() is incorrect. See the parameters here. If you are not sure about parameters you need to look them up -- just google "c++ fgets" and you will find the link I posted.

What are A, B and C?? fgets() reads an entire line, so unless you want to skip 3 lines it should only appear once.

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

You can easily skip the first line by calling fgets() to read it, then just don't use what was read.

Do any of the strings contain spaces? fscanf with %s can't read the spaces. If there are no spaces with the strings then the fscanf line you posted will probably work because tabs are considered white space. %s stops reading at the first white space character (space, tab, newline, and backspace).

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

UDP is not recommended for long distances because there is no guarentee that the packets will ever arrive. TCP is best for that.

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

Youtube tutoral. Google will give you other tutorials too.

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

what language are you writing this with??

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

(1) Use your compiler's debugger so that you can step through the execution of the program and see where it stops.

(2) or scatter some print statements around.

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

why did you post all that code???

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

You'll have to explain the "constraints" -- I don't want to guess or read your mind.

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

Temp in the 40s and 50s (F) today and tomorrow. All the snow we got the other day is nearly gone now.

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

recursion will be faster in general. It varies from being quite a bit faster (in simple cases) to making almost no difference at all, but it's very rare, with a good optimizing compiler, that a recursive implementation will be much slower.

If you prototype the two functions, yes recursive algorithm will probably be faster than the iterative algorithm to solve the same problem. But the clock cycles needed to perform recursion is most definetly more than the clock cycles need to perform a loop.

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

Yes, loops can crash too, but everything else being equal recursion is more likely to crash than loops.

Like i said and i will repeat that again. There are situations recursion is the right way to go.

I absolutely agree with that statement, and I posted a link to one example of it.

Pretty and elegant codes are well contained and maintained, easy to debug than a worm code.

Yes, but not if pretty and elegent code crashes due to to finite memory constraints. There is no one right way -- it all depends on the situation, on the hardware and on the operating system. What may work perfectly fine on one operating system and computer may not work at all on another.

BTW: Don't try to win with Mike -- he never loses :)

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

My theory is that we are like a virus growing in someone's test tube. Travel far enough in space and we will hit the wall of the test tube. Big Bang theory is when someone shakes up that test tube to start our universe all over again. Scientists on TV have said they think the Big Bang has happened several times, so someone puts a modicule in a test tube and watches it explode -- Bang! and we're started.

Why not?? good as any other explanation. :)

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

Why would you need a reference book for that?? It's happened to me hundreds of time, which is why desk checking and other in-house checking is required. At my last job they had an entire team doing nothing but testing the software that the programmer's wrote and/or modified. Ever hear of "beta testing"?? The intent is for the general public to test out the program, find bugs, and report back to the software company. The people at Blizzard Inc. do that all the time with their games and Microsoft does it occasionally too with some of thier products.

Probably any book about software development will have a few sentences about product testing before release. The subject isn't complicated enough to require more than one or two sentences.

the developer does not feel needs the level of test we provide

Quite possibly he has not been writing code very long, or maybe the program just isn't all that complicated.

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

If you don't want to do it all inside that function then you have to pass a pointer to the function.

#include<iostream>
#include<fstream>

ifstream& readfile(ifstream& myfile)
{
    if( getline(myfile, str_line) )
    {
       cout<<str_line;
    }
    return myfile;
}

int main()
{
   ifstream myfile("myfile.txt");
   if( myfile.is_open() )
   { 
       while( readfile(myfile) )
       {
          // do something
       }
    }
}

But why go to all the trouble to call readline() when you could call getline() easier directly within the while loop? No one in his right mind would attempt to code it the way you described -- too complicated and just too damned sloooow.

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

Please mail me that source code

Please deposit $10,000.00 USD in my PayPal account and I'll do that sometime within the next 12 months or so.

Just for curiosity -- why would "Data of Joining" be in a phone book??? Joining what???

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

I think Mike explained it pretty well in his last post -- recursion can often run the program out of stack space and when that happens your entire program will just crash. Now, you tell us which is more eligent -- pretty code that crashes often, or not-so-pretty code that runs without problems?

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

You can't call that function in a loop to read the file line-by-line because the file pointer is destroyed as soon as the function returns to it's caller. You need to call that function only once, then have that function read each line in a loop. You will most likely have to reorganize the way the rest of your program works. You didn't post it so I don't know what it does.

The check for file open on line 10 doesn't work they way you want it to because the file is automatically closed when the function exits. The flag on line 8 therefore becomes useless. What that function should do is something like this:

open the file
start of loop
   read a line
   exit this loop if end-of-file reached
   process the line
   go back to start of loop
end of loop

It can be easily coded like this:

ifstream infile("myfile.txt");
std::string line;

if( infile.is_open() )
{
    while( getline(infile,line) )
    {
      // do something here
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Science is highly specialized, a doctor knows no more about quantum

I didn't read his biograph on wiki so I thought he had Ph.D., but now that you mention it I see in wiki he has a medical degree. That makes his book even more suspect. But it might be interesting to read, as a sci-fi book.

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

Watched Hansel and Gretel again tonight -- very good action-packed movie

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

78's! Did you have to crank the handle too and direct the trumpet-thingy?

I had one of those when I was a kid -- still have some of the old glass 8 inch records for it that I've saved all these years (probably 50+ years)

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

That's a little hard to swallow. Parents-nonhuman, child-human

Isn't that the whole of evolution theory? If you believe evolution then you must also believe that at some time some human's parents were non-human.

I pretty much think the author of this book is as much a crackpot as Erich von Daniken's "Chariots of the Gods", which was an interesting and amusing book, but only from sci-fi standpoint. Dr. Lanza probably read too much Stephen King and saw too much Star Trek.

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

That function is ok for MS-Windows -- but not if the program is running on *nix or other op.

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

Somehow I don't see the point of hving this discusion any more.

They why are you continuing it???

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

Dr. Robert Lanza write a book titled “Biocentrism: How Life and Consciousness Are the Keys to Understanding the Nature of the Universe“ which apparently (I have not read it, and wouldn't understand it even if I did) states that consciousness continues after the body dies.

The theory implies that death of consciousness simply does not exist. It only exists as a thought because people identify themselves with their body. They believe that the body is going to perish, sooner or later, thinking their consciousness will disappear too. If the body generates consciousness, then consciousness dies when the body dies. But if the body receives consciousness in the same way that a cable box receives satellite signals, then of course consciousness does not end at the death of the physical vehicle. In fact, consciousness exists outside of constraints of time and space. It is able to be anywhere: in the human body and outside of it. In other words, it is non-local in the same sense that quantum objects are non-local. .

(click here for full article)

Our souls are in fact constructed from the very fabric of the universe – and may have existed since the beginning of time. Our brains are just receivers and amplifiers for the proto-consciousness that is intrinsic to the fabric of space-time.

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

Yea, the need to refresh after posting causes a few problems, at least for me. Try editing a post a couple times without refresh -- some edits will be lost and you'll have to do it all over again.

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

Great! I was hoping you did that already :)

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

Since emails include all of the posts in the thread

Can you limit that to just the last 3 or 4 posts in the thread? I don't want an email with all 1,000 replies each time someone replys to one of the Geek's Lounge threads.

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

I though the whole purpose of this is so paople can use smartphones and tablets. I don't think there are a whole lot of members who have tables, but that's just my guess. Maybe a poll would be nice to find out.

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

The wrapping is why I said I doubt its usefullyness on smartphones.

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

Are you using a smartphone? Also, I see that each email contains all the posts in the thread -- is there a cutoff, such as will it quote all 1000 or so post that are in a few of these threads?

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

It looks ok to me, I'm now getting all the emails. But I still question the usefullness in the Software forums because the code is unformatted and very difficult to read. But it would be ok in all the other discussion forums.

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

There are several ways to do it, but one way is: in a loop call getline() to read each line, then for each line read use stringstream object to split it into individual tokens. Post the code you have attempted and we can help you some more.

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

Yes, that's the way the mailing lists I have belonged to worked. Makes for a lot of email in my mailbox, but that's the price we have to pay for joining mailing lists.

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

Once again, the request is for the number of items in the file, not its byte size.

I'm not too sure about that -- the OP never said which one he/she wants. The subject of this thread indicates file size, not the number of integers in the file. But maybe the OP didn't know what he/she wanted.

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

Well if I think for just a second the size of int is possible to obtain by sizeof(int).

Yes, but only in memory. That has no relationship to the number of bytes it occupies in a text file. sizeof(int) will produce the same in binary files assuming the programmer wrote out the integer as binary instead of text. But then you can use cin >> x; on bianry data.

And if you work with binary file mode, in the heder of a file there is a infomation how big or small is the file

No there isn't, unless the program that generated the file put it there. Normally binary files have no such indication of file size at the beginning.

But, if is possible to get it without opening it,

Yes, call stat() which, among other info, will return the file size.

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

I just read an email where someone created a new thread in the c++ forum. For curosity I used my browser to read the questions, and there was already 3 responses, yet I did not get emails for any of them. Shouldn't there be emails for the responses too?? No point in me attempting to answer a question which has already been resolved.

by just visiting the forum I can estimate based on the title whether I'll be able to help, so won't get notices from each thread created.

Two problems with that sentence: (1) you can do the same by reading the email, and (2) thread subjects are not a very good indication of what the question is about.

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

There is no one right answer, it depends on how complex the data and how complex the queries. If you want to do rather involved SQL type queries then you'd have to use an SQL compliant database such as MySQL. But if the file is rather small then just read it into memory once and do all the in-memory seareches you want.

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

Post the new code please.

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

You need to post code becuse my eyesight is not good enough to see your computer's monitor from where I am sitting.

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

I don't see how one could possibly post code from smartphone -- How could you do copy from a compiler so thatt it can be pasted within email?? For software forums it's just a lot easier to us PC browser. Your mailing list will probably work in places that do not require copy/paste.

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

Is anyone else annoyed about how bad spelling is becoming among people who text a lot? I see the next 100 years evolving an entirely new English dictionary as a result of cellphone texts. Really unfortunate for humankind.

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

The limitation is on lines 13 and 16 -- only room for 15 number of characters in the password. If you want more then change those two lines.

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

other than doing it myself!

Yes, that's what we want you to do, then ask questions about what you don't understand. We're not going to write the program for you, but help you to write it yourself. Give a man a fish and he will eat for one meal, teach a man how to fish and he will eat for life.

aroshkhan commented: agree (Y) :D +0
ddanbe commented: The proverb! +14