473,398 Members | 2,343 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,398 software developers and data experts.

Unresolved external 'atoi'

11
Hey, hopefully one of you can help me... I keep getting an unresolved external 'atoi(char)' and I dont know why.. here is the code

#include <iostream>
#include <stdlib.h>
using namespace std;


void main()
{
int atoi(char c);
int a, b, c, d, e, f, g;
int const row = 10;
int const col = 4;
char array[row];
char phonenum[row][col] = {
{ "0***"},
{ "1***"},
{ "2ABC"},
{ "3DEF"},
{ "4GHI"},
{ "5JKL"},
{ "6MNO"},
{ "7PRS"},
{ "8TUV"},
{ "9WXY"} };

cout<< "enter number" <<endl;
cin>> array;

for(a = 0; a < 3; a++)
{
for(b = 0; b < 3; b++)
{
for(c = 0; c < 3; c++)
{
for(d = 0; d < 3; d++)
{
for(e = 0; e < 3; e++)
{
for(f = 0; f < 3; f++)
{
for(g = 0; g < 3; g++)
{
cout<< phonenum[atoi(array[0])][a], phonenum[atoi(array[1])][a], phonenum[atoi(array[2])][c], phonenum[atoi(array[3])][d], phonenum[atoi(array[4])][e], phonenum[atoi(array[5])][f], phonenum[atoi(array[6])][g];
}

}
}
}
}
}
}
}
May 2 '07 #1
9 3996
svlsr2000
181 Expert 100+
The standard library declares atoi as

int atoi ( const char * str );.Though c++ allows function overloading You should define your function. :)
May 2 '07 #2
Would
11
im not sure what you mean by define my function I have it initialized and the header file what else should i do here?
May 2 '07 #3
mac11
256 100+
Expand|Select|Wrap|Line Numbers
  1. int atoi(char c);
You don't need this line if you want to use the atoi() thats provided by stdlib.h. If you want to write your own atoi function (overload it) you should move this line outside of main and add a function body to it....

Most likely, you want to use the stdlib atoi() so just remove that line and adjust your code to work with it.
May 2 '07 #4
Would
11
when i remove the initialization for the atoi in my code it says "could not find a match for atoi(char) in function main.. im completely lost here we didnt cover this in class my teacher just suggested it for the route i am going with this code
May 3 '07 #5
Would
11
i invite anyone to tell me whats going on here please!
May 3 '07 #6
svlsr2000
181 Expert 100+
stdlib.h defines/ declares atoi as int atoi(char *); You are trying to use atoi(char)
May 3 '07 #7
svlsr2000
181 Expert 100+
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <stdlib.h> 
  3. using namespace std;
  4.  
  5.  
  6. void main()
  7. {
  8. int atoi(char c);
  9. int a, b, c, d, e, f, g;
  10. int const row = 10;
  11. int const col = 4;
  12. char array[row];
  13. char phonenum[row][col] = { 
  14. { "0***"},
  15. { "1***"},
  16. { "2ABC"},
  17. { "3DEF"},
  18. { "4GHI"},
  19. { "5JKL"},
  20. { "6MNO"}, 
  21. { "7PRS"},
  22. { "8TUV"},
  23. { "9WXY"} };
  24.  
  25. cout<< "enter number" <<endl;
  26. cin>> array;
  27.  
  28. for(a = 0; a < 3; a++)
  29. {
  30. for(b = 0; b < 3; b++)
  31. {
  32. for(c = 0; c < 3; c++)
  33. {
  34. for(d = 0; d < 3; d++)
  35. {
  36. for(e = 0; e < 3; e++)
  37. {
  38. for(f = 0; f < 3; f++)
  39. {
  40. for(g = 0; g < 3; g++)
  41. {
  42. cout<< phonenum[atoi(array[0])][a], phonenum[atoi(array[1])][a], phonenum[atoi(array[2])][c], phonenum[atoi(array[3])][d], phonenum[atoi(array[4])][e], phonenum[atoi(array[5])][f], phonenum[atoi(array[6])][g];
  43. }
  44.  
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51.  
in phonenum[atoi(array[0])][a], array [0] is treated as character and not as pointer to character. atoi expects pointer to string, ie you can say array of character terminated with null.
May 3 '07 #8
Would
11
i honestly dont know enough about c++ to know what you mean by that...
May 3 '07 #9
svlsr2000
181 Expert 100+
char a[] = "hello";

here a can be used as a pointer. The compiler terminates this with Null for us.
Here 'a' can also be used as pointer to string.

a[0], a[1] and so on are treated as character.

In your call to atoi, your using array[0], which is treated as character, where as atoi expects pointer to string or character.

I thing this answers your question
May 3 '07 #10

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

Similar topics

4
by: Rodolphe | last post by:
Hello, I'm French so sorry for my approximate English. When I try to compile a project under Visual C++ 6.0, I've got the following errors : applicap.obj : error LNK2001: unresolved external...
0
by: Ida | last post by:
Hi, I am trying to build an dll with Microsoft Visual C++ but during the linking phase I get linking errors. Script.obj : error LNK2019: unresolved external symbol __imp__PyString_AsString...
1
by: Aravind | last post by:
we have two files: 1. rc4.c (defines one function "create_pin()") 2. MyImpl.c(calling the function "create_pin()"),This implements JNI method. 1.When I am trying to create .dll file with one...
5
by: cschettle | last post by:
I think you need to link with msvcrt.lib ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
2
by: Maydogg6 | last post by:
I need a hand with some stubborn link errors. I'm trying to recreate and old program from 6.0 into .NET, but for some reason when I try to compile I'm getting linking errors for all my function...
6
by: sadegh | last post by:
Hi I have a problem with my program in VC++6 When I compile it, the following errors are listed. I spend a lot of time on the groups.google.com to find its reason, but none of comments could...
0
by: Ryan Gaffuri | last post by:
hlink72@hotmail.com (Eric) wrote in message news:<ab8d8b14.0308220550.54fb5f22@posting.google.com>... LNK1120 is a standard C++ error. you using Visual C++? Means your references a class that...
2
by: =?Utf-8?B?YmFzaA==?= | last post by:
Hello, I am compiling a CPP code using Visual studion .net 2003. I get the following error, despite having windldap.h and wldap32.dll in my include and lib paths. Here is the error. uuid.lib...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.