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

You need to initialize the array count_let to all 0's before calling that loop. You can do that when it is declared, like this:
int count_let[20] = {0};

Since you are reading the file one character at a time it is not necessary to read the characters into an array. Notice fgetc returns an integer, not char.

int c;
while( (c = fgetc(ip_file)) != EOF)
{


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

Any reason why? I thought limiting it to inside the function is better practice.

What if you have a couple dozen functions that need access to std namespace? Are you going to put that line inside each function? No, just put it after all includes and be done with it.

It's not good practice to even have that statement in the program because it brings everything within std namespace into the program, whether it needs the symbols or not. There are two better ways to code it:

  1. using std::array; // <<< put that after all includes

  2. std::array<int, 5> cppArr = // << declare the namespace when the variable is declared

I've seen it both ways but I favor the first of those two methods because you don't have to keep repeating std:: over and over and over again.

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

That program will have a similar problem when the value of transpose is large enough to make an unsigned char overflow, such as 'z' is 122 decimal, so any value of transpose greater than (255 - 122) = 133 will cause data overflow.

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

Can you only enter alph characters such as 'a' to 'z', no caps or other special characters?

for(int value = 0; value < strlen(userInput); value++)

calling strlen() in a loop like that is poor programming practice because the return value never changes and its time consuming. Here is a better way to code that loop

for(int value = 0; userInput[value] != '\0'; value++){

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

this will help me decide whether to closethis thread or keep it open.

You don't have that choice. Only mods and admins can do that. All the rest of us can do is mark it solved.

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

LadderLogic is rightfully a language in itself.

Yes, I agree with that, I used to work for a company that installed large character printers and scanners on production lines in factories. Devices that used LadderLogic language were often used to bridge the gap between computer and production line hardware, such as opening and closing gates.

I'm not convinced that DaniWeb needs forums specifically for industrial automation. AFAIK no one has ever posted a question or comment about it.

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

As far as I'm concerned, the only sane thing to do is a clean install.

Sometimes that doesn't work. My Asus computer is touch-screen, a clean install of Windows 8 did not contain the correct tourhscreen drivers, but an upgrade from Win7 to Win8 did have it. I read in some other sites that other people have had the same problem. My Asus computer is only about a year old, so it shouldn't have that sort of problem.

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

IMHO Windows 8 for PC is a load of shit, a complet failure worse than Vista. I installed it, then all hell broke loose and I lost everything. I tried to repair the file system but it was too far gone. Today I removed Windows 8 and replace it with Windows 7. The second thing I disliked about Windows 8 was lack of a Start button. Bad move for Microsoft after users have been using a Start button for over 10 years. I wish I could return Windows 8 for refund but that isn't possible because the package was opened. So I'll just use the dvd as a beer coster.

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

pleassse i want the answer after one week because the last date after one week.

I'll be glad to do your homework for you. Just deposit $1,000.00 USD into my PayPal account for each program you want written. No guarentees of course.

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

I'm happy I don't have to worry about exams any more :) :) :)

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

First post here, please go easy on me :)

Fat chance :)

Move line 6 to line 3 so that it is not inside any function.

Your program compiles without errors/warnings using VC++ 2012, as you already stated. It won't compile using Code::Blocks w/MinGW. I don't know enough about that compiler to explain why.

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

you will have to recompile the program. Whether it will compile depends on your compiler. You will have a better chance at that if you use Code::Blocks with MinGW compiler, which is a port of the same compiler on *nix.

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

What version of MS-Windows do you have? Using Turbo C is a little like putting a Model T engine made in 1890 into a 2012 automobile. You might try running Turbo C in DosBox

Musa_Jutt commented: thankx +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

get MinGW, but I don't know which version of gcc it uses.

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

You posted your program but failed to ask a question. We aren't mind readers.

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

Everyone, everywhere, can help by donating whatever they can afford to the American Red Cross at at this link.. Be aware that other organizations may not be legitimate and may be scams. You should check out other organizations thoroughly before donating to them.

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

Windows 8 didn't cause my hard drive crash -- incompatible antivirus program caused it.

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

I have discovered that the problem I had may have been caused by incompatible anti-virus program, not Windows 8.

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

Couldn't you buy it locally, on DVD? I have no idea what you can do other than what you have already done.

My recommendation: stick with Windows 7, do not upgrade to Windows 8. I upgraded and now regret it becuse all the data on my hard drive is now destroyed. A new update was downloaded this morning and my computer hasn't worked since.

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

Have you opened the package yet? how long ago did you install it? Windows 8 is out now so I don't know if you can still get Windows 7. If you live in USA ask someone at Best Buy.

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

What os and browser are you using at work? Is it owned by US government?

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

string book = "\0"

Huh? Why not just this: string book = ""; It's not necessary to specify '\0' because all string are null terminated. I don't think that is really a problem, just style. Nobody, like NOBODY, ever does that.

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

I installed Windows 8 the other day on my tough-screen computer, this morning it installed an update. Guess what? CRASH! I can't even boot it, I was using the IE10 when I got about 15 error messages about hard drive problems, then let it scan my hard drive. Lots of problems shown. Now the computer won't boot at all.

My suggestion to others: don't bother installing Windows 8, it isn't worth it.

[edit]The hard drive problems are soooo bad that Windows 8 install disk can't fix them. My only real option was to wipe the hard drive clean and start all over again with a clean computer, losing all my files. Thankfully I have backups of the important files.

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

In the read function, the loop should look like below. If that doesn't fix the problem then I suspect the problem is in the BOOK class constructor. You need to post it.

while( file>>ID>>bookName>>author>>book_type>>copies>>price>>status)
{

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

It doesn't look like the file has been read at that point. main() just opens the file but doesn't read it into the patient and hospital arrays.

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

Thanks. It didn't use that one,so I just saved it in my Pictures folder then changed the shortcut icon.

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

I put a shortcut on my desktop to DaniWeb.com, but it shows some default icon. Do you have one that I can repalace it with?

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

The ONE word solution certainly would NOT be "religion" because that's been the cause of most of the world's violance.

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

I'm using Win8 Start Button. Not quite the same as Windows 7 but close enough. I also noticed the calculator program is missing, so I downloaded a trial version of one because I use it every once in awhile.

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

Great News: Using Chrome browser Esc works as expected in Windows 8, no need to click anywhere. And yes, it still retains the text you previously entered.

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

I discovered the Start button was just replaced by a hidden menu on the right side of the screen. If you have a touch screen just slide a finder from the right side of the screen left and a menu will appear that, among other things, contains a link to the Control Panel.

Reverend@ the Start app I installed is free, not a trial version.

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

Not really. There are many threads on the net about that, here's one about rounding.

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

Is there any other advantage beside that?

Probably. One thing: no Start menu. Microsoft, in their infinite wisdom, decided we didn't need to access the Control Panel. However, all isn't lost, there is a free app that adds it back.

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

One advantage I have seen so far here at DaniWeb is that when I use the Code button I don't have to refresh the screen to see the results (line numbers, etc.). I don't know if this is something that Dani changed recently or the result of Windows 8/Chrome. In either event, it's a nice feature that has been the source of some frustration with DaniWeb's markup language.

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

One of the "problems" with floating point is that many numbers can not be represented exactly as you have found out. It's due to the way floats/doubles are represented in memory. A full explanation is given here.

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

Did you read this thread? If not, you should.

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

When you declare variables within a switch statement you have to enclose the case statement in { and }, something like this:

case 7:
{
   FILE* fp;
   // rest of case 7 code goes here
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I just got Windows 8 Pro installed on my touch-screen PC, pretty nice so far. Bought it today at Best Buy for only $65.95 USD, which is about 1/2 normal price. Everything went smoothly with no problems at all, took, about 1 1/2 hours. I installed it as an upgrade to Windows 7 and had it retain all my windows settings and files.

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

how to write in code ,to return the last index and the element in the lastindex

lastindex is not an array, so your question makes no sense.

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

But you have to tell the compiler which library file (.lib) to link to.

CB uses gcc compiler/linker so libraries are the same as *nix, which are *.a, not *.lib, so you might have a library named libmylib.a. The name of the libraries are compiler-dependent, many MS-Windows compiler such as Microsoft and Borland use *.lib as previously explained by dx9, but CB does not.

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

then just print arr[lastindex] (assuming the value of lastindex == 4)

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

No, search option only tells the linker where to find them. Add library names in Project --> Build Options --> linker settings tab.

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

Purely subjective. I like Facebook better, but others may not.

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

you mean you want to display the data in reverse order, such as 1 2 3 4 5 instead of 5 4 3 2 1? You already have a pointer named l, just use it

int* l = &arr[lastindex];
while( l > arr )
{
   printf("%d\n", *l);
   --l;
 }

or you could do this:

while( lastindex >= 0)
{
   printf("%d\n", arr[lastindex]);
   --lastindex;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What, specificially, do you need help with? Post what you have done so far, even if its wrong, and ask specific question(s).

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

If you use relative path then your project may not work because some *.cpp files are in different folders so the relative locations will change depending on the location of the *.cpp files. Use full paths and it should be ok.

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

BTW, don't use index[arr] because that form is rarely, if ever, used in real life. If you intend to index an array, then do so like this: arr[index]

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

lastindex[arr] is the same thing as arr[lastindex], which is 1, not 4. So the comparsion can be rewritten like this:
if(arr[arr[lastindex]] < 4)

Now, start from the innermost expression arr[lastindex] which is 1, then evaluate arr[1] which is 4.

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

arr[4]= 1
1 < 4 is true so it has to print right,but its printing wrong

Yes, but that isn't what is being compared. arr[1] is 4