Hi
When I compile my files I get the following:
driver.c: In function `main':
driver.c:49: warning: assignment makes integer from pointer without a
cast
driver.c:50: warning: assignment makes integer from pointer without a
cast
driver.c:51: warning: assignment makes integer from pointer without a
cast
getparams.c: In function `getparams':
getparams.c:8: warning: assignment makes pointer from integer without
a cast
lines 49, 50 and 51 in driver refer to the lines
m = params[0];
n = params[1];
k = params[2];
and line 8 in getparams refers to the line
params[x] = atoi(argv[val]);
Can someone tell me why I'm getting this error message and how to fix
it. Needless to say, the program when ran from command prompt as for
example:
./test.o n y 4 5 6
does produce the desired output.
Please help find the problem thats causing the error.
Kind regards
Dawn
A cut down version of my main driver.c file looks like this:
#include <stdio.h>
#include <stdlib.h>
extern void getparams(int argc, char *argv[], int *params[]);
int main(int argc, char *argv[])
{
int c, m, n, k, lda, ldb, ldc;
int *params[10];
if(argc > 1)
{
/*Run getparams*/
getparams(argc, argv, params);
m = params[0];
n = params[1];
k = params[2];
printf("m= %i", m);
printf("n= %i", n);
printf("k= %i", k);
}
return 0;
}
My getparams.c file looks like this:
void getparams(int argc, char *argv[], int *params[])
{
int val=2, x=0;
for(val=2; val<argc; val++)
{
params[x] = atoi(argv[val]);
x++;
}
} 4 36136
Dawn Minnis wrote on 20/02/05 : #include <stdio.h> #include <stdlib.h>
extern void getparams(int argc, char *argv[], int *params[]);
int main(int argc, char *argv[]) { int c, m, n, k, lda, ldb, ldc; int *params[10];
An array of pointers ? Is it really what you want? I guess that what
you actually want is:
int params[10];
Same here:
void getparams(int argc, char *argv[], int *params[])
void getparams(int argc, char *argv[], int params[])
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
"Mal nommer les choses c'est ajouter du malheur au
monde." -- Albert Camus.
In article <72**************************@posting.google.com >,
Dawn Minnis <da*********@gmail.com> wrote: Hi
When I compile my files I get the following:
driver.c: In function `main': driver.c:49: warning: assignment makes integer from pointer without a cast driver.c:50: warning: assignment makes integer from pointer without a cast driver.c:51: warning: assignment makes integer from pointer without a cast getparams.c: In function `getparams': getparams.c:8: warning: assignment makes pointer from integer without a cast
....#include <stdio.h> #include <stdlib.h>
extern void getparams(int argc, char *argv[], int *params/*[]*/); int main(int argc, char *argv[]) { int c, m, n, k, lda, ldb, ldc;
int /***/params[10]; if(argc > 1) { /*Run getparams*/ getparams(argc, argv, params);
HTH.
Dawn Minnis wrote: Hi
When I compile my files I get the following:
driver.c: In function `main': driver.c:49: warning: assignment makes integer from pointer without a cast driver.c:50: warning: assignment makes integer from pointer without a cast driver.c:51: warning: assignment makes integer from pointer without a cast getparams.c: In function `getparams': getparams.c:8: warning: assignment makes pointer from integer without a cast
lines 49, 50 and 51 in driver refer to the lines m = params[0]; n = params[1]; k = params[2];
Look at your declarations:
int c, m, n, k, lda, ldb, ldc; int *params[10];
m, n, and k are declared as ints, the elements of params are
pointers-to-ints. Why are you doing this silly thing?
Needless to say, the program when ran from command prompt as for example: ./test.o n y 4 5 6 does produce the desired output.
The above is bullshit. The "needless to say" is flat wrong. Storing
ints in pointers is not something that "needless to say" produces the
desired output.
Just get rid of all those extra '*'s:
#include <stdio.h>
#include <stdlib.h>
extern void getparams(int argc, char *argv[], int params[]);
/* mha: removed bogus '*' */
int main(int argc, char *argv[])
{
int m, n, k;
int params[10]; /* mha: removed bogus '*' */
if (argc > 1) {
/* Run getparams */
getparams(argc, argv, params);
m = params[0];
n = params[1];
k = params[2];
printf("m= %i", m);
printf("n= %i", n);
printf("k= %i", k);
}
putchar('\n'); /* mha: added. Without this '\n'
ending the last line of output, your
program does not have predictable
behavior */
return 0;
}
void getparams(int argc, char *argv[], int params[])
/* mha: removed bogus '*' */
{
int val = 2, x = 0;
for (val = 2; val < argc; val++) {
params[x] = atoi(argv[val]);
x++;
}
}
Wow
You couldn't half tell I don't know what I'm talking about half the
time. That worked. Thank you so much for that. Thats all it took to
get rid of the warnings and perform a clean compile.
Thanks ever so much. It's been bugging me for days now.
Dawn This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: MK |
last post by:
I am a newbie. Please help. The following warning is issued by gcc-3.2.2
compiler (pc Linux):
==================================================================
read_raw_data.c:51: warning:...
|
by: David Ford |
last post by:
I have a macro that I use across the board for freeing ram. I'd like to
clean up my code so I don't get these warnings.
#define sfree(x) _internal_sfree((void **)&x)
#define _internal_sfree(x)...
|
by: jose_luis_fdez_diaz_news |
last post by:
Hi,
If I don't include <libgen.h> I get then warnig below in regcmp call:
warning: improper pointer/integer combination: op "="
but if I include it the warning is not shown, but them program...
|
by: francescomoi |
last post by:
Hi.
I'm trying to compile this piece of source:
-------------------------------------------
int id;
while(row1 = mysql_fetch_row(rs1))
{
id = atoi((int)row1);...
|
by: junky_fellow |
last post by:
Consider the following piece of code:
struct junk {
int i_val;
int i_val1;
char c_val;
};
int main(void)
{
|
by: metalinc |
last post by:
hi...im new to C programming...need help...tried to run this code but got this error
fork.c: In function ‘parse’:
fork.c:44: warning: comparison between pointer and integer
fork.c:51: warning:...
|
by: mrmattborja |
last post by:
Hello,
Here is a program I'm playing around with for fun in the process of learning C. The objective is to create a function filesize() and call it from within the main() section to retrieve the...
|
by: drhowarddrfine |
last post by:
warning: assignment makes pointer from integer without a cast
I get that when I compile a C file where the function is defined as this:
char **getvars()
and the calling function has this...
|
by: woods1313drew |
last post by:
The following code in c+ gives me the warning assignment makes integer from pointer without a cast.
destination is set as char destination to limit the input string to 10 characters.
name is an...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |