I want to print the results of the best schedule array (which is shorted in a specific way in the find_best_scedule function) through the main program. Actually I should print the results by using a second function named print_best_schedule, but this seems too complicated and I prefer to do one step at a time.
The problem is that I don't know how to print the array through the pointer "ptr".
Here is the code I wrote: -
void find_best_schedule(int TASK_TIMES[6][3],int *ptr[7]);
-
int print_best_schedule(int best_schedule[]);
-
-
...
-
-
int TASK_TIMES[][3] = { {1,15,3}, {2,7,9}, {3,4,10}, {4,7,6}, {5,10,9}, {6,4,5}, {7,7,8}};
-
int ptrs, k;
-
find_best_schedule(TASK_TIMES, &ptrs);
-
-
for(k=0; k<7; k++)
-
printf("%d",ptrs[k]);//Here is the problem
-
-
-
...
-
-
void find_best_schedule(int TASK_TIMES[6][3],int*ptr[7])
-
{
-
int i, k, p, n, min, cell, in_schedule[7], best_schedule[7];
-
-
<snipped:- code populating best scheduled array>
-
-
ptr[7]=&best_schedule[0];
-
-
}
8 1496
Is this code compiling for you.?
I was not able to compile this.
You are passing an integer address and getting it in a pointer array...how it will compile
Raghuram
Please help me!!!!!!!!!! I have the same problem in a homework and i can't find the problem. Can you check exactly in the code what to correct?
Thank you
Xrysa
Banfa 9,065
Expert Mod 8TB
cube, you have made a number of posts now, please start using code tags ([code=c] ... [/code]) round code you post. I have added them for you this time.
Please help me!!!!!!!!!!
Didn't you read that your code won't compile??
Your function needs a pointer to an array of 7 int and you are passing a pointer to a single int.
cube, you have made a number of posts now, please start using code tags (
) round code you post. I have added them for you this time.
Sorry, I post this code late after midnight and I did look for it but I didn't remember which symbol to click. Now I know!!!
Please help me!!!!!!!!!!
Didn't you read that your code won't compile??
Your function needs a pointer to an array of 7 int and you are passing a pointer to a single int.
Please note that I wasn't the one that "Pleased for help" but Xrysa.
Thank you for pointing it out for me. I did try to read about pointers and arrays before post this code but I couldn't understand much, about the particular assignment.
Can I find the answer to my question in the article "Arrays Revealed"?
Finally there is a more simple way to do this without pointers.
But just to enrich my knowledge I would like to find how to do it both ways.
Can I find the answer to my question in the article "Arrays Revealed"?
Read the article and let me know if I have to add sonmething to it.
Also,
Please note that I wasn't the one that "Pleased for help" but Xrysa.
Sorry. My mistake.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matteo Settenvini |
last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using
g++ 3.3.x.
I had been taught that an array isn't a lot different from a pointer
(in fact you can use the pointer arithmetics to...
|
by: buda |
last post by:
Hi,
given the following code,
....
int main( void ) {
char *a = { "abc", "def", "ghijkl", "o", "prs" }; // for example
....
}
|
by: Steve |
last post by:
Can anyone tell me if I can have an array of functions that take a variable
number of parameters? If it is possible I'd like to know how to declare the
array and the functions as its elements. I am...
|
by: Pete |
last post by:
Can someone please help, I'm trying to pass an array to a function, do some
operation on that array, then return it for further use. The errors I am
getting for the following code are, differences...
|
by: Bern McCarty |
last post by:
I have a DLL written in C++ (it's really C code that was adjusted to compile
OK as C++) that I compile successfully into IL with the /CLR switch of
Visual C 7.1. I use the resultant library...
|
by: ashutosh |
last post by:
hi,
i am making the dll for clamav antivirus libraray so that i can make
activex control for windows.
i complied the library successfully and make the Libclamav.dll file using
win32 Api...
|
by: Albert |
last post by:
So structures are useful to group variables, so you can to refer to a
collection as a single entity. Wouldn't it be useful to also have the
ability to collect variable and functions?
Ask K&R...
|
by: googlinggoogler |
last post by:
Hi
This should all be pretty standard C stuff, but I'm going to use terms
like mouse callback to communicate what Im tyring to do.
Basically I have my program whirling around in an infinite...
|
by: J de Boyne Pollard |
last post by:
MThe library functions which are included to allow process
Mlaunch, forking, and termination, imply that it is both
Mpossible and desirable for a process to fork itself. This is
Ma fundamental...
|
by: sanjay.vasudevan |
last post by:
Why are the following declarations invalid in C?
int f();
int f();
It would be great if anyone could also explain the design decision
for such a language restricton.
Regards,
Sanjay
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |