LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-15-2013, 06:31 PM   #1
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
A question about atoi() i C...


I'm trying to understand why I get this error when I compile
functions.c:521: warning: passing argument 2 of 'AddRecord' makes pointer from integer without a cast
arg2 is a char pointer already why is it complaining?
Code:
char *arg1;
	char *arg2;
	char *arg3;
	char *arg4;

	arg1 = strtok(args, " ");
	arg2 = strtok(NULL, " ");
	arg3 = strtok(NULL, " ");
	arg4 = strtok(NULL, " ");
Code:
if (strncmp(arg1, "add", 1) == 0) {
		if (arg4 == NULL)
			AddRecord(conn, NULL, arg2, arg3);
		else
			AddRecord(conn, atoi(arg2), arg3, arg4);  // line 521
		DatabaseWrite(conn, filename);
}
 
Old 02-15-2013, 06:52 PM   #2
j13ett5
LQ Newbie
 
Registered: Nov 2005
Distribution: debian
Posts: 13

Rep: Reputation: 1
It's complaining because atoi converts char-pointer into an integer represention of what it finds at the poited-to location.

Drop the atoi

AddRecord(conn, arg2, arg3, arg4); // line 521
 
Old 02-15-2013, 10:01 PM   #3
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Original Poster
Rep: Reputation: 70
Ah ok yes I see now. Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
atoi() function results in improper value harishisnow Programming 6 08-16-2011 10:58 AM
[SOLVED] atoi() not giving correct answer iqra Programming 8 06-20-2010 08:58 AM
Segmentation fault - atoi(argv[2]) psrujan Programming 1 07-01-2007 11:32 AM
Problem with atoi in pthreads jones507 Programming 1 10-16-2003 02:42 PM
convert integer to string (atoi?) lea Programming 6 10-11-2002 05:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration