Adak 419 Nearly a Posting Virtuoso

I gave you explicit instructions on how to get started in graphics mode, but you've ignored them, and just now you're posting up some half-baked lines of code with no logic in them, as a "clue". And they're not even from you!

My first "clue" is that you won't have the assignment done by tomorrow, having done such a lousy effort, so far. My second "clue", is that you will not pass your class, because programming involves a lot of work - and you have not shown any.

You have a great resource here, and I was looking forward to working with you on this, but you won't work. I feel like I've been kicking a dead horse here, and I'm tired of it.

Goodbye.

jonsca commented: Yes +2
Ancient Dragon commented: Bravo :) +27
tux4life commented: Agree :) +8
hinduengg commented: Nice one! +4
Adak 419 Nearly a Posting Virtuoso

-------------------------------------------


I'm using the very very old one,

Turbo C++ Version 3.0. Borland Int.

I know this turbo is very old but it requires this in our school.. ;'(

so, guys can you help me now and stop arguing about what version I'm using,? I just need an example for my program.. I really need it.. :'( Please?

I'm using the even older, Turbo C/C++ version 1.01 from Borland International, and I have *already* told you exactly where your answers can be found -

***One More Time***:

You already have examples of the programs you need, right in your help files!!

Read my earlier post (not the previous post of mine, but my post before that one). The details of the keystrokes may be different for version 3.0, but the help files will be there. All you have to do is copy and paste into your new program, remove the duplicate include lines and such, and add a small amount of user input.

I am NOT going to make your program for you. Either you get to work and show it, or you will get nothing more from me.

Ancient Dragon commented: Good :) +27
Adak 419 Nearly a Posting Virtuoso

On the right hand side of the forum, there is a green box labeled "Related Forum Features", which includes a C tutorial. Google has several others.

Most C forums that are active, have either a tutorial, a FAQ, or both.

You can't do what you want with (almost) no knowledge of C. It's like trying to lose weight - first you have to restrict your calories enough, and THEN you start to lose weight. It doesn't work the other way around, no matter who you are, or how much you might pray for it to be like that. ;)

We had to work to learn C, and you will also - or you won't learn C. Asking for help finding a tutorial, when you have a link right in front of you, is somewhat disingenuous, imo.

Adak 419 Nearly a Posting Virtuoso

I don't know about helping you "get" code, but I can help you *write* code for this histogram.

What do you have for input, (how is it organized, especially)?

Post up your code that you have so far - you do need to show some work, here - and make a small input file example and attach it to your post (or just wrap it in code tags, also and post it as well).

You should read up on just what a histogram is, if you don't already know. (I think you do know).

And tell us what you're stumped on, please. "Help" is not all that helpful, oddly. "Help with *SOMETHING*, is much more -- yeah! Helpful!! :)

Adak 419 Nearly a Posting Virtuoso

This program shows how to do a simple selection sort (almost the same as a bubble sort), keying on one column of a 2D array.

/* shows how to a 2D array, using one column (the last column) as the key.
*/

#include <stdio.h>

void printArray(const int a[3][4]);

int main()

{
  int pass;
  int i;
  int j, k;
  int hold;
  int array1[3][4]= {5,34,78,112,1,56,86,142,3,45,29,74};

  printf("Employee number   1st Quarter Sales   2nd Quarters Sales   Total Sales\n");

  printArray(array1);
  
  for (i = 0; i < 3; i++) {
    for(j = i+1; j < 3 ; j++) {
      if(array1[i][3] < array1[j][3]) {  //swap all cols in the row
        hold= array1[i][3];                  //this is our key column
        array1[i][3]=array1[j][3];
        array1[j][3] = hold;

        hold = array1[i][2];
        array1[i][2] = array1[j][2];
        array1[j][2] = hold;

        hold = array1[i][1];
        array1[i][1] = array1[j][1];
        array1[j][1] = hold;

        hold = array1[i][0];
        array1[i][0] = array1[j][0];
        array1[j][0] = hold;

      }
    }
  }
  printArray(array1);

     // system("PAUSE");

  printf("\n\n\t\t\t     press enter when ready");
  getchar();
  return 0;
}

void printArray(const int a[3][4])

{
  int i;
  int j;
  printf("\n\n");
  for (i =0; i < 3; i++) {
    for (j=0; j < 4; j++) {
      printf("%9d  ", a[i][j]);
    }
    printf("\n");
  }
}

This is not the best way to do this, however. (Imagine doing this with a 2D array with 100 columns <eek!>.) The best way is to NOT move any of the data, and swap values in an index (or pointer) auxiliary array, instead. That allows the data to be printed out in sorted order, but no data will have to be moved.

aslk commented: Thank you for your time. +1
Adak 419 Nearly a Posting Virtuoso

On this forum, we try to NOT give out code, until after the poster (you), have shown some work to make the program.

We want to HELP, not become "homework central" for every student who would like to have their assignment done for them. Do you see what I mean?

Actually, I already wrote up a little program just for you, but I'm not going to post it unless and until you show some EFFORT.

So get posting! ;)

Adak 419 Nearly a Posting Virtuoso

Welcome to the forum, Shubh. :)

A few important suggestions for you:

1) For your problem, start a new thread. Using someone else's is called "thread hijacking", and will get people upset with you.

More people will see your thread when you start a new one, and respond.

2) When you post code, ALWAYS highlight it and click on the # icon in the advanced editor, or "Code" word in the quick reply window. That makes your code keep good formatting on the forum. Hopefully, you use good formatting in your code, to help spot bugs and show the relationship between lines of code that are primary, and those that are dependent (indented 2 - 5 spaces).

Salem commented: Barely contained restraint here ;) +19
Adak 419 Nearly a Posting Virtuoso

What we require, is that you take a stab at doing this assignment, and post up your code. Tell us where you're stuck.

We can help, and the fact that it's Turbo C will not be a problem. I use an early version of it, myself. (The C side of Turbo C/C++, actually).

There are all kinds of examples and tutorials out there, and you should have class notes and books for reference, as well.

So get to it, and post back when you have something specific to ask about.

"I need help ", by itself, just means "I'm too busy to be bothered". In which case, we are too busy, as well.

Adak 419 Nearly a Posting Virtuoso

When you are fscanf()'ing a char array, you need to just have the name of the array - that IS a const pointer to the base of the array.

You need to remove the '&' in front of the char arrays that you will be scanning:

while (!feof(fp)){

fscanf(fp,"%d\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n",&barc,&aulastname,&aufirstname,&stulastname,&stufirstname,&bktitle,&genre,&date);

if ((strcmpi(search_aulname,aulastname)==0)&&(strcmpi(search_aufname,aufirstname)==0)&&(strcmpi(search_stulname,stulastname)==0)&&(strcmpi(searchbk_title,bktitle)==0)){

Use the '&' for numbers of all kinds, and for char's, but not for strings. Goes for fscanf(), scanf(), sscanf(), etc.

Adak 419 Nearly a Posting Virtuoso

Yes, we can help, but I see no program to help.

We help - we do not *do* the homework for you.

Salem commented: Well said +19
Adak 419 Nearly a Posting Virtuoso

:( giving error
program has encountered a problem and needs to close. we are sorry for inconvenience..............send report....
tell me what to do now !

This is incorrect:

fprintf(strea, "%s %s %d %s",&name[10],&course_enrolled[10],&id_number,&date_of_birth[10]);

Try:
fprintf(strea, %s %s %d %s", name[i], course_enrolled[i], &id_number, date_of_birth[i]);

//The name of the array is an address to the base of the array, so array's need no & in //them, here.

In your first for loop, you need to do (as I understand your program), three things:

1) get input, either from file, or from the user, using fscanf(), or scanf().
2) print the data onto the screen with printf()
3) write the data to a file, with fprintf().

EACH part of the input loops may need a printf() and fprintf() line of code in them.

I don't see that in your program.

Just post your compiler errors or warnings. Operating system warnings do no good - but almost always refer to your program trying to read or write data somewhere it shouldn't, in memory.

Also, this is wrong. You open the file for reading, and then you are writing to the file:

strea=fopen("STUDENT.FIL","r");
        fprintf(strea,"NAME= %s\tCOURSE ENTITLLED= %s\t ID NUMBER= %d\t DATE OF BIRTH= %s\tAVERAGE= %f\n",name,course_enrolled,id_number,date_of_birth,average);
        fclose(strea);

Open the file for append or writing, or writing and reading, if you want to write to it.

It's after 2:00 a.m. here, so I have to go to bed. Good luck. You need to study harder …

Nick Evan commented: Good help +7
Adak 419 Nearly a Posting Virtuoso

Imagine you're in a large house, with several rooms. Each room is a function:

*you can only carry in *copies* of what you want, into each room, unless it's already been put there (ie, it's global in scope).

*you can only walk out of a room, carrying *one* item

*if the item you walk out with was created within the room, then the item will self-destruct right at the doorway as you walk out out of the room

*each room is organized so you can more easily do some type of work, in it. It has a natural purpose (sorting, searching, reading data, writing data, editing data, getting input from the user, etc.)

Hope that helps.

What you want to do is post up some code (the smaller and simpler the better), that you don't understand, or that doesn't work correctly, and ask specific questions about what you don't understand about that code. General questions like this, are too vague, and really require a chapter in a book, to answer thoroughly.

jephthah commented: that's kinda cool. never heard anyone put it like that before. +4
Adak 419 Nearly a Posting Virtuoso

I compiled from the IDE.

If using int main doesn't help correct your program's starting address, can you just set the address, explicitly?

jephthah commented: good spot! +3