WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So perhaps time has existed in one state or another for ever.

I think you're right. We had time when I lived in Michigan. Now that I'm in Minnesota, time seems to work here, too.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

We need to get some better information.

You've been bouncing all over this program for 4 pages and still don't have your file input working right yet? In your first post you say

The main problem i am having is the storing the file character by character into the 3D array.

Your last post (#32) says:

i want to input the text file, character by character, in the array but i seem to be getting, problems...

After all this help, why is your input not working yet? Haven't we been helpful at all? Ignore everything else and get your input working!

Another problem is this -- you say (again)

i want to input the text file, character by character, in the array but i seem to be getting, problems...

Do you need more help with your problems? If so, do you think describing the problems might be beneficial?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hey there guys,

First time poster here, so I apologize for being a rookie.

Then you should have been posting for the past year. Then you wouldn't be a rookie :icon_mrgreen:

This is my first VB class and im having a hard time with For-Next loops.

As you can see it is only an issue of having the maximum number of stars on top, rather than at the bottom. I figure the issue is just reworking the loop, or adding another nested loop, but I am having a hard time finding the solution.

You aren't having a hard time. you're second-guessing yourself. You already know the answer (bolded above).

You need one loop for each line. Within that loop you need another loop for each '*' on that line.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

But just remember not to call your fake user Ancient Dragon Jr. Maybe Old Lizard or Decrepid Firebreather, something like that would hide your identity...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

At the very beginning of the program, open a file names XXX.XXX for writing. Write something (anything) into it. Close the file.

Now search for the file XXX.XXX on disk. When you find it, that is where your input file must be. Move it there.

Delete that new code and try again.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Go back to this code:

char cabin[3][4][13]={' '};
    char ch, res;
    int num, lvl=0, row=0, col=0;
    
    for(int a=0; a<3; a++)//Levels
      {
       for(int b=0; b<13; b++)//Rows
       {
        for(int c=0; c<4; c++)//Colunms
        {
            cabin[a][b][c] = '*';
        }
       }
      }

and fix your indecies and loops. They must match, and yours do not. You have an abc confusion going on...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

... Sweden, Germany, BeNeLux, etc.

Isn't BeNeLux a vacuum cleaner? :icon_twisted:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you try to fail, and succeed, which have you done?

Don't know, but it might have something to do with a play called "Springtime for Hitler" :icon_mrgreen:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You should be checking for EOF during read. Look up your read function to see how EOF works.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Oh yeah, didn't notice that. char letters[6]; can only access [0] to [5] - 6 values int mem[3]; can only access [0] to [2] - 3 values

thomas_naveen commented: didn't notice mem[3] access. +1
jonsca commented: Excellent job too, I guess ;) +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I am running into multiple issues. I am not exactly sure how to go about rolling the dice,

Call rand() -- the value returned is one die roll.

summing them together,

Start with a value set to 0 as a total. Add the rolled die to it.

and how all the loops will work together for the desired output.

Think. Write the ideas on paper.
** Get one die (the computer only rolls 1 at a time).
** Roll it to the specifications of possible input
** -- 3 dice - 3 rolls;
** -- # rolls to check - 10 - repeat above 10 times. You don't want to try 10,000
** Write down each and every detail of how you are getting to an answer. When you understand that, you're ready to start coding.

Once again I am new to all of this.

Duh, ya think? :icon_wink: If you're having a hard time with simple tasks, you're new. That's OK. We all were once. No need to remind everyone.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Since you are writing a student project on rolling dice, not solving universal chaos theory, rand() is more than adequate.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hey, if it works sometimes, it works. That's just a simple, logical fact.

Au contraire. If it only sometimes works, it's broken.

Do you work? If so,would you accept a $100 drop in pay this week because the payroll program only makes a mistake once in a while and doesn't add your hours correctly? After all, it is only once in 3 months...

Close enough doesn't work in computers.

jephthah commented: aha +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

fgets(buf, n, stdin) is just as easy as gets(buf) . It's more keystrokes but that is not a function of ease. It's also safer, that's why we recommend it. Too many people come whining to us with errors caused by gets() .

And no, if something allows errors to happen it doesn't work.

Salem commented: Nice +19
Aia commented: Worth pointing out. +8
Ancient Dragon commented: Absolutely +27
iamthwee commented: I wet myself when I read this. +11
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

alphabet from lower to upper , using ascii
what logic should be use to convert small letters into capital using ascii codes??
for example ascci code for A is 65 and ascii code for a is 97
how can i coonvert from integers to character ?

Such confusing responses....

What is the difference (numerically) between 'A' and 'a'?
What about 'B' and 'b'?
'C' and 'c'?
Notice a pattern?

Therein lies your logic for conversion.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Do you mean that you don't want to have to press enter after each (one character) number is entered? If so, then yes it is possible. I'm sure I have seen this done a different way, but here is one way anyhow:

char num1, num2, num3, num4, num5;
    cout << "enter 5 numbers:";
    num1 = cin.get();
    num2 = cin.get();
    num3 = cin.get();
    num4 = cin.get();
    num5 = cin.get();
 
    cout<<endl<<num1<<endl<<num2<<endl<<num3<<endl<<num4<<endl<<num5<<"\nPretty cool huh!\n";

You'll still have to press enter after the 5 numbers are entered, and this doesn't have error checking, of course. BUT if you enter 54321 (enter) then you will have your desired output. You could also enter a 5-letter word if you wanted to, since cin.get() gets one character.

That doesn't enter 5 numbers. It enters 5 characters.

I'm more on Vernon's side. Simply enter the numbers as distinct numbers: Enter: 1 2 3 4 5

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes we can. Start by reading the Member Rules and the useful posts at the top of the forum.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

the dean and the administration above him are responsible for enforcing teh use of shitty compilers. I believe the highest eschelon of your national university system is receiving kickbacks... er, i mean "incentives" from Borland corporation to perpetuate their shittiness all over the Second World.

I kind of doubt that. If they are getting kickbacks, they'd be passing out at least Borland 2006, not Turbo 3.0.

I'm sure the crappy compilers are being used because that's what the instructor learned on and he's never bothered to keep up with the industry (he's in academia after all) and just keeps plodding along thinking Borland is still king of the compilers. They are just lazy SOBs.

jephthah commented: good point. +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

No, it's a real shot (actually two) of that street.

As google (or whoever) goes around taking pictures for the street views, the cars and pedestrians move between shots. Sometimes not enough so you get that effect.

If you look at the LA link (if not active check around the Hollywood, CA area, on Sunset, Vine, Hollywood) when you look up, youl
'll see a present a bird left on the camera dome...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OP seems to have record being passed in as a char* . Shouldn't it pass in as struct PATIENT * record ?

Good point. I missed that :icon_redface: I assumed it was the struct and didn't look close..

jonsca commented: No worries WaltP, I've had like 15+ of those in a row +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

:D When you post answers to questions here do people jump down your throat about using bad techniques, commands, formatting? :twisted:
that would be clue #1...:icon_mrgreen:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I might be using anything...but I am using Dev-C++ for now. I also have VS C++ 2008 Express, but haven't used it much yet.

In addition (if it hasn't been pointed out yet) Mixing cin with getchar() should not be done. Stick to one style.

Meh...

Whenever I don't feel like writing that whole system pause thing, I do this:

#define pause system("PAUSE");

so then its usage would be:

pause;

This is one of the worst suggestions I've ever seen... How does this eliminate using system("PAUSE") as everyone else is suggesting? :icon_rolleyes:

MyrtleTurtle commented: That's why I like sites like this. There is so much they don't teach in class. Thanks for the info. +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I was in the middle of moving some discussion posts into their own thread from a help thread and got his nose bent because it wasn't pretty yet. The discussion was getting long and was unnecessary to the OP. J thinks I was doing it to make him look bad. You know how he is.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Open the file with "wb". "w" is text by default.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I don't see where you even read my post, let alone tried to answer my questions.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Ahh, forget it...

jephthah commented: :P +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Is this nearly bulletproof?

/*  Does not verify date components (month <=12 etc), not 
    the purpose of  the task. 

    Handles 3 number fields (a date) separated by / - . and SPACE
 */
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>

int isSeparator(char ch)
{
    if (ch == '/')  return 1;
    if (ch == '-')  return 1;
    if (ch == '.')  return 1;
    if (ch == ' ')  return 1;
    if (ch == '\n') return 1;
    return 0;
}

int main()
{
    int date[3];
    int i;
    char buf[200] = {0};
    char *p;
    
    printf("Enter date: ");
    fgets(buf, 200, stdin);
    
    p = buf;
    i = 0;
    while (*p != '\n' && *p != 0 && i < 3 )
    {
        if (isdigit(*p))
        {
            date[i++] = atoi(p);
            while (isdigit(*p))  p++;
            if (isSeparator(*p)) p++;
              else              break;  // non-date character
        }
        else  break;                    // non-date character
    }
    if (i != 3) printf ("Illegal Date Format");
      else
      {
        printf("%2d/%02d/%04d ", date[0], date[1], date[2]);
      }
    return 0;
}
tux4life commented: Nice code :) +8
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
[B]random[/B]   Macro that returns an integer.
 Syntax:
   random(num);
   int random(int num);

Not every compiler may have this, but some do.

Sorry, that doesn't cut it. If not all compilers (only TurboC as far as I can tell) have it, it is not a reserved word. And any use as a variable will override the macro definition.

Or are you also implying that when using DevC I can't create a variable named clrscr or gotoxy because it's defined in TurboC3?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Have a beer for me. That'll do....

jonsca commented: Does that go for anybody? ;) +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

[edit]
WOW, I guess I took a little too long to post... WaltP already covered most of it. Your tolower() is still not correct though.

To quote Fran, the Progressive weirdo -- "Happens to me all the time!" :)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Then you did it wrong. But my psychic powers aren't working today so I can't tell why.

churni commented: thanks for the help - you really are a genius in my eyes! +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

well, it turned a colon & asterisk into a love emoticon. sometimes u learn things by accident. WaltP: could u please explain step-by-step how to do that?

Look in the start menu under accessories.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What compiler?

Why not just do your own ceil() function? hour_labor = (int)(square_footage*(8.0/500.0)) + 1;

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

this is written on the book
1990 by The Waite Group, Inc.

20 years old? Never learn from a computer book older than yourself! Jeez! :icon_rolleyes:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

... what my teacher teach is only the basic.

No, what your teacher teaches is completely non-standard C that cannot be used in today's industry. TurboC++ is over 17 years old and is so outdated at least 3/4ths of your code cannot possibly be compiled on any current compiler. TurboC 3 I assume? Makes it almost 20 years old.

I hope you aren't paying a lot for your C++ class. You are getting ripped off.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In addition to what Banfa said, you need to learn formatting. Your code is completely unreadable. You should not ask someone else to try and help you with code that cannot be followed.

As for lifelines, you need to keep track of all three individually. Use an array.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Open the file in WORD and output the file as TEXT.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

@WaltP , Our teacher teaching us from the basic and they told us to use such functions, i don't know any other function to use then these void main(void) and clrscr () & getch () , can you tell me which functions should i use istead of the functions above ?

Then you are being seriously mistaught. The last version of Turbo C was ver 4 in 1993. That's 17 years ago. Many compilers have been following the changes in the standards and the industry since then. Maybe you should ask your instructors why they insist on using such old tools when they have been surpassed by many free compilers since then.

Xufyan commented: u'r great :) +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1) Speak English. nid? Use sentences. Violation of the Rules.
2) Give you code? Why should we do something you're not willing to do? What's in it for us? Violation of the Rules.
3) ASAP? What makes you so blamed important? All these other member's posts are less important than your program? Why?
4) email? Why should you get special treatment? Violation of the Rules.
5) Special treatment because you're a freshman? No wonder upper classmen dislike freshmen -- they're primadonnas.
6) How can you possibly defend something you didn't write?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i can get this to round up can anyone help? i have been using the ceil function but its not working right i get an error saying it cant be used as a function.
i put ceil b4 the ( in this formula below and i put ceil b4 the ( in the 2nd formula.

Are you unable to post the exact error? What does "not working right" mean? Why can't ceil be used?

You should know by now it's a waste of time to post questions without details because we just ask questions about stuff you didn't tell us. Then we have to wait for you. Hours and many posts later, you get an answer. Cut that time by figuring out what might help us understand and just explain the entire problem in one post. Errors and all.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Can anyone explain whats wrong with this program

void main(void) - see this clrscr (); - very old non-standard function that hasn't existed since 1986 getch (); - non-standard function that is very non-portable, works in very few compilers
and no formatting making the program hard to follow.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i dont know how to explain this any better, without resorting to code. here it is 'explained' in pseudocode

first problem:

for i = 1 to CHARS
{
    for j = 1 to i
    {
        print "$"
    }
    print \newline
}

second problem:

for i = 1 to CHARS 
{
    for j = (CHARS - 1) to (CHARS - i) 
    {
         print char('A' + j)
    }
    print \newline
}

That's not pseudocode. That's BASIC. :icon_wink:

jephthah commented: going to look it up on wikipedia, now :P +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Please ignore fr3aky's poorly formatted unreadable code. It will teach you very little that is useful.

fr3aky, here we do not not give programs to people, we help them solve their own problems. And when we post code the help, the code is formatted, readable, and useful.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

He called you a turabo.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Your first problem is that

Like I said most of it is still half written and Im still fidgitting with it.

Stop fidgitting with it. Take one task, write it. Test it. Perfect it. Then move to the next task.

I'd recommend starting with the display function. Write it completely first -- passing parameters so you can display either player's board.

Then write the ship placement function. Takes board, ship, starting position, and either the direction (up, left,...) or ending position.

Now the user input function, which calls the perfected ship placement function. Then modify the user input function to create the computer 'input' function.

Etc....

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
1.) system("PAUSE");
2.) system("PAUSE>NUL");

Neither are recommended... 3.) cin.ignore(2); Useless without cin.get() to read the character to enter.

Use a combination if cin.ignore followed by getline to pause your code.


By the way, software does not collapse. Please explain what you really see in detail otherwise all we are doing is guessing -- which is all these two posts are doing anyway.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You apologize, but you don't bother to correct the situation. Like everyone else, I don't know what you need help with since you can't be bothered to explain it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes, I could do that. But it would be a lot easier only having 1 type to keep track of. Else I would have to check if it's 11 and create a new char/string and print that instead.

Not true. Just create a name string array available for all displays: string cardDisplay[] = {"Ace", "2", "3",...,"10","Jack"...}; then each and every time you display the card, use cardDisplay[card]

jonsca commented: Works too! +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

P.S. I dont want to use a cin.ignore() and cin.get() after one another as the double enter makes things sluggish and clunky feeling.

Yes you do. cin.ignore is not an input, it clears the buffer. Then to make it wait, you use the cin.get .

But, as firstPerson mentioned, getline would be better. cin.get only gets the 1st character, and if the user types anything more than ENTER, you've still got a problem. getline solves that problem.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Usually, I'd tell you fflush(stdin) is wrong. But since you are using a thirty year old compiler with functions that haven't existed since the mid-80's, I'll let it go this time. I hope you aren't learning on this compiler for a potential career. You will have to unlearn a great deal. cprintf() is the Turbo graphics version of printf()

Salem commented: Wow, you made it through nearly 1K lines of TurboCrap +19