Problem in header file and variables

Hi! When i run the codes, in turbo c++, from the resource, i've got the message it says:

1.) error edit: unable to open include file 'RW/RANDOM.H'
2.) error edit: Unable to open include file 'ARMORY.H'
3.) error edit: 'string' cannot start a parameter declaration
4.) error edit: ) expected

it is a codes for my periodic table of elements' function which is my project and this is the only problem i have. What should i change or replace from armory and random? Help me please. Thank you in advance!

1
2
3
4
5
6
7
8
#include <iostream.h>
#include <conio.h>
#include <rw/random.h>
#include <string.h>
#include <armory.h>
//---------------------------------------------------------------------------
void Table(string Name, double Number, int Group, int Period, string Formula, string Charge, double Mass, int Neutrons, string Special)
{
Last edited on
I don't know about the 3 and 4 part of your question, you would need to include corresponding code for us to be able to see what's wrong there. Also with the errors you get you always get the line at which the error occurs, so that you can track where it comes from and maybe try to figure it out.

If you want to include headers which you've made yourself. You should use " instead of <>
So in your case:
1
2
3
4
5
#include <iostream>
#include <conio.h>
#include "RW/RANDOM_H"
#include <string>
#include "ARMORY_H" 


Hope this helps
Thank you for your response sir. BTW, this is where i get the source code: https://www.cprogramming.com/cgi-bin/source/source.cgi?action=Jump&LID=50

Anw, i tried to change the <> to "" but still now working. I am not the one who made the header in the program i have just got this on internet for my project's function. Any other idea sir, how to fix this?
turbo c++ predates these language updates. It predates the STL, so you can't use <string>, for example. random is also not available. you will have to rewrite the code to use C-strings and rand() from stdlib or get a new compiler. Predating the stl also means that you need the .h versions of includes, like cstdlib is not there, its stdlib.h and iostream.h and so on.
Last edited on
thank you again for your response and time for explaining. Well anw, i've got another program but i'll try to fix this in my own. It is just hard for me, as a beginner, to do something like this. haha! Thank you again sir!
If it's not working with "" and you didn't make the headers, first did you check that you do have said header files (rw/random.h and armory.h), for if you don't have them, you'll get errors when including them.

Second did you check that they are in the same folder as your main.cpp?

What error is your compiler giving you?
Thanks for the tip sir! BTW sir, could you help me how to use the if(....) and the for(i...) and also the gotoxy?

1
2
3
4
5
6
7
8
9
10
11
12
 gotoxy(12,4);
 cout<<"Ú"<<"Ä"<<"Ä"<<"¿";
 gotoxy(63,4);
 cout<<"Ú"<<"Ä"<<"Ä"<<"¿";
 gotoxy(12,5);cout<<"³";
 gotoxy(15,5);cout<<"³";
 gotoxy(63,5);cout<<"³";
 gotoxy(66,5);cout<<"³";
 gotoxy(12,6);cout<<"Ã"<<"Ä"<<"Ä"<<"´";
 gotoxy(48,6);cout<<"Ú";
 for(i=51;i<=60;i++)
  if(i%3==0)
gotoxy is nonstandard tool that moves the cursor to the x/y location on the screen, useful to over-write existing text with new text in output.

if statements you can google, but real quick, the format is
if(condition)
{
//do things if condition was true
}
else
{
//do things if condition is false
}

this one says that if the remainder (%) of i divided by 3 is zero, do something

for loops have 2 forms, this is the classic form.
for(initialize/create variable; condition; action ) where action is USUALLY used to modify the loop variable but may also be used for simple loops as the entire loop body.
this one says start i at 51, until i is 60, increment i and do things. so it loops for 51,52,53,54... 60 checking to see if i%3== 0. This is poor if there was no else on that if statement, by the way, you can do less work to get the same result via
for(i = 51; i <= 60; i+=3)
//remove if statement
{
whatever was in the if statement.
}
we know that 51 is divisible by 3 evenly, so 51%3==0 is true. we know that adding 3 each time will give true. so we loop 51,54,57,60 and do less work.
Last edited on
Second did you check that they are in the same folder as your main.cpp?

- Yes sir!

What error is your compiler giving you?

-Same message sir. Which is the 4 message that are given in my post. sad. Well, i search for the armory and the random. There are no random header file and armory sad. But it is fine now. i have a new function, it is working but still there a bug that some not work.

Sorry for asking and for late reply. I just want to learn from you, an expert, about these codes. I have a lot of questions here.

1.) void element(int,int); - why void? what is the application of
element here?

2.) void welcome_screen() -> why void? How it functions
the welcome_screen()
3.) {
4.) clrscr();
5.) for(int x=50;x>=20;x--) -> I really don't understand the
looping or iteration. What is the purpose of these codes, here?
(BTW, why decrement and why not increment?)

6.) {
7.) delay(160); -> Why there is a delay here?

8.) gotoxy(x,12); -> Where do we use this usually?

9.) cputs(" statement "); -> does cputs and printf and cout is
same? What are the difference sir?

10.) gotoxy(x,14);
11.) cputs(" statement");
12.) gotoxy(x,16);
13.) cputs("statement");

Thank you sir again. :D
Last edited on
1) a void function returns no value. element is a function, why it is void depends on what the author of the code is doing. An example of this would be if element just displayed its parameters, it does not need to return a value for that. It could be doing uglies with globals, hopefully not.

2) same as #1, a display function does not need a return type.

5) start at 50, stop at 20, subtract 1 each time. Why decrement? This is the logic the programmer wanted, they wanted to process data from 50 to 20 for some reason.

7) the programmer wanted one.

8) this is nonstandard. It is, as I said, used to move the cursor. you can use it to re-draw the whole screen, or to back up and replace 1 word, for example if you are processing a long time and print progress, rather than 50000 output statements of what % done you are at, you can just have 1 and overwrite it each time. Old code used to alternate /-\ or such symbols using this to make it look like it was spinning.

9) cout is c++ and preferred in c++ code. printf is C and not preferred (though I like it better for writing a lot of doubles, its easier to format). cputs is not standard for either language and is some extension. If I remember it may be lower level and faster, which mattered in like 1989, but my memory is fading fast on stuff like that.

we simply can't see enough from your examples to really get what it is doing in all cases.

and as I said, random is post turbo. It does not exist for that tool.
Last edited on
Thank you for your response sir. Somehow, i understand some of those things but i guess, to understand more is i have to try it out by myself by running it in compiler. Btw, it has 1k+ blocks that's why i post it gradually. It is a for periodic table of elements. Would you like to see, to understand what the author's purpose of why he include or use those syntax?

Really appreicate it sir. Thank you for giving me some time to help me to understand these shits.
Topic archived. No new replies allowed.