473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

warning: assignment makes integer from pointer without a cast

Hi,

I am receiving this error when I attempt to assign a value from argv[1] so I can use it as an int.

Here is the code:

int main(int argc, char** argv)
{
FILE* ifp;
int row;

/* Check the command line arguments */
if(argc != 4)
{
fprintf(stderr,"Not enough command line arguments!\n");
fprintf(stderr,"Use %s ROWS COLS OUTPUTFILE\n", argv[0]);
exit(-1);
}

ifp = fopen(argv[3], "r");
if(ifp == NULL)
{
fprintf(stderr,"File %s could not be opened!\n", argv[3]);
exit(-2);
}

row = argv[1];

return 0;
}


My command line arguments are: a.out (number) (number) (filename)

I want to use the numbers entered to create a 2d array, but I can't figure out how to use those numbers entered.

Any help is appreciated. Thank you
Jan 26 '07 #1
3 1888
Motoma
3,237 Expert 2GB
Hi,

I am receiving this error when I attempt to assign a value from argv[1] so I can use it as an int.

Here is the code:

int main(int argc, char** argv)
{
FILE* ifp;
int row;

/* Check the command line arguments */
if(argc != 4)
{
fprintf(stderr,"Not enough command line arguments!\n");
fprintf(stderr,"Use %s ROWS COLS OUTPUTFILE\n", argv[0]);
exit(-1);
}

ifp = fopen(argv[3], "r");
if(ifp == NULL)
{
fprintf(stderr,"File %s could not be opened!\n", argv[3]);
exit(-2);
}

row = argv[1];

return 0;
}


My command line arguments are: a.out (number) (number) (filename)

I want to use the numbers entered to create a 2d array, but I can't figure out how to use those numbers entered.

Any help is appreciated. Thank you

Try this:
Expand|Select|Wrap|Line Numbers
  1.    row = atoi(argv[1]);
  2.  
Jan 26 '07 #2
Try this:
Expand|Select|Wrap|Line Numbers
  1.    row = atoi(argv[1]);
  2.  

thank you very much. would you mind explaining what the atoi is. i just want to make sure it's ok with what we have done in class.

thanks again
Jan 26 '07 #3
Motoma
3,237 Expert 2GB
thank you very much. would you mind explaining what the atoi is. i just want to make sure it's ok with what we have done in class.

thanks again
atoi() is a function that transforms character string (aka a) to an integer (aka i).
Jan 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

27
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:...
16
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)...
4
by: Dawn Minnis | last post by:
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...
16
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...
2
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);...
29
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) {
4
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:...
3
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...
10
drhowarddrfine
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...
1
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.