473,503 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error executing link.exe??

The function of the program is to output the longest word in a
sentence.

#include<stdio.H>
#include<string.H>
main()
{int alphabetic(char);
int longest(char []);
int i;
char line[100];
printf("input one line");
gets(line);
printf("the longest word is:");
for(i=longest(line);alphabetic(line[i]);i++)
printf("%c",line[i]);
}

int alphabetic(char c)
{if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
return(1);
else
return(0);
}

int longest(char string[])
{int alphabetic(char c);
int i,length=0,len=0,place,inaword=0; /*inaword=0 refers to the
"cursor" is not in a word*/
for(i=0;i<=strlen(string);i++)
{if(alpabetic(string[i]))
{inaword=1;
place=i;
len++;}
else
{inaword=0;
if(length<len)
{length=len;
place=i;
len=0;
}
}
}
return(place);
}
But when i try to link(visual c++6), it said
"Linking...
c.obj : error LNK2001: unresolved external symbol _alpabetic
Debug/c.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe."

I don't understand why.Can anyone help me? Thx!
Aug 17 '08 #1
13 5586
su*******@gmail.com wrote:

Here's the declaration:
{int alphabetic(char);
And the error message:
"Linking...
c.obj : error LNK2001: unresolved external symbol _alpabetic
I don't understand why.Can anyone help me? Thx!
I'm not "Thx", but even I can notice that "alpabetic" and "alphabetic"
are not the same.
Aug 17 '08 #2
raashid bhatt wrote:
what are u doing man function prototype inside another function?
int alphabetic(char);
int longest(char []);
There is nothing wrong with having a declaration inside another
function. If that fellow with the short name "u" can do it.
take them outside main
There is no need.
>
and append __cdecl before fucntion name
There is nothing in the C programming language named "__cdecl" and, even
if there were, it has nothing to do with his problem, which was simply
misspelling his identifier.
Aug 17 '08 #3
su*******@gmail.com wrote:
The function of the program is to output the longest word in a
sentence.

#include<stdio.H>
#include<string.H>
These shouldn't have a capital H.
main()
That should be int main(void)
{int alphabetic(char);
int longest(char []);
int i;
char line[100];
printf("input one line");
gets(line);
Never, ever use gets. Use fgets(line, 100, stdin) and change 100 to a
named constant.
printf("the longest word is:");
for(i=longest(line);alphabetic(line[i]);i++)
printf("%c",line[i]);
}

int alphabetic(char c)
{if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
return(1);
else
return(0);
}

int longest(char string[])
{int alphabetic(char c);
int i,length=0,len=0,place,inaword=0; /*inaword=0 refers to the
"cursor" is not in a word*/
for(i=0;i<=strlen(string);i++)
{if(alpabetic(string[i]))
You spelt alphabetic wrong here.
--
Ian Collins.
Aug 17 '08 #4
raashid bhatt wrote:
>
what are u doing man function prototype inside another function?
int alphabetic(char);
int longest(char []);
There's nothing wrong with putting function prototypes in a function body.
take them outside main

and append __cdecl before fucntion name
Why on Earth would anyone do that?

--
Ian Collins.
Aug 17 '08 #5
On Aug 16, 7:16*pm, surlog...@gmail.com wrote:
The function of the program is to output the longest word in a
sentence.

#include<stdio.H>
#include<string.H>
main()
{int alphabetic(char);
*int longest(char []);
*int i;
*char line[100];
*printf("input one line");
*gets(line);
*printf("the longest word is:");
*for(i=longest(line);alphabetic(line[i]);i++)
* * * * *printf("%c",line[i]);

}
what are u doing man function prototype inside another function?
int alphabetic(char);
int longest(char []);

take them outside main

and append __cdecl before fucntion name
Thanks!!
Aug 17 '08 #6
On 2008-08-17, su*******@gmail.com <su*******@gmail.comwrote:
The function of the program is to output the longest word in a
sentence.
Well, you've got a number of problems (I won't mention stylistic
concerns, but suffice to say this code is very hard to read):
#include<stdio.H>
#include<string.H>
These should be .h, not .H.
main()
int main(void)
{int alphabetic(char);
int longest(char []);
int i;
char line[100];
printf("input one line");
gets(line);
*Never* use gets(). It is bug unto itself. Instead try
fgets(line, sizeof line, stdin);
printf("the longest word is:");
for(i=longest(line);alphabetic(line[i]);i++)
There is a standard C function (macro?) isalpha() you could use instead
of alphabetic().
printf("%c",line[i]);
Another standard C function, putc(), will do this for you.
}

int alphabetic(char c)
{if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
return(1);
else
return(0);
}
There's no guarantee that this will work: what if you are using a
character set where letters are not consecutive? Use isalpha() instead.
>
int longest(char string[])
{int alphabetic(char c);
Consider giving function prototypes file scope, and moving them to
shared header files. This makes them easier to update.
int i,length=0,len=0,place,inaword=0; /*inaword=0 refers to the
"cursor" is not in a word*/
for(i=0;i<=strlen(string);i++)
{if(alpabetic(string[i]))
Here is your reported error. You spelt alphabetic() wrong.
{inaword=1;
place=i;
len++;}
else
{inaword=0;
if(length<len)
{length=len;
place=i;
len=0;
}
}
}
return(place);
}
Yikes! Consider using pointers instead to make this function
more concise. You could do it with three local variables, as
opposed to the 6 you are using now.

--
Andrew Poelstra ap*******@wpsoftware.com
To email me, use the above email addresss with .com set to .net
Aug 17 '08 #7
On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), su*******@gmail.com wrote:
>The function of the program is to output the longest word in a
sentence.

#include<stdio.H>
C is case sensitive. The correct header is stdio.h.
>#include<string.H>
main()
{int alphabetic(char);
int longest(char []);
int i;
char line[100];
printf("input one line");
gets(line);
printf("the longest word is:");
for(i=longest(line);alphabetic(line[i]);i++)
Horizontal white space is not completely cost free but it is a very
cheap way to improve the readability of your code. At a minimum, add
a space after each semicolon.
> printf("%c",line[i]);
}

int alphabetic(char c)
This entire function is unnecessary as there is already a standard C
function to do this.
>{if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
This test is valid in ASCII. However, it yields incorrect results in
EBCDIC.
> return(1);
return is a statement, not a function. The parentheses are allowed
but unnecessary.
else
return(0);
}

int longest(char string[])
The name string is reserved for the implementation. It would benefit
you not to use names starting with "str".
>{int alphabetic(char c);
If you would place your prototypes at file scope at the beginning of
your source, you would not have to repeat them.
>int i,length=0,len=0,place,inaword=0; /*inaword=0 refers to the
"cursor" is not in a word*/
for(i=0;i<=strlen(string);i++)
{if(alpabetic(string[i]))
Maybe your keyboard has a problem with the character "h". Here it is
missing.
> {inaword=1;
place=i;
You only want to do this if this is the very first character in the
word. Otherwise place will end up as the index of the last character
in the word.
> len++;}
else
{inaword=0;
if(length<len)
{length=len;
place=i;
I'm pretty sure you don't want this line here at all. This will cause
place to be the index of the character one byte beyond the end of the
word.
> len=0;
}
}
}
return(place);
}
But when i try to link(visual c++6), it said
"Linking...
c.obj : error LNK2001: unresolved external symbol _alpabetic
Debug/c.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe."

I don't understand why.Can anyone help me? Thx!
--
Remove del for email
Aug 17 '08 #8
Barry Schwarz wrote:
On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), su*******@gmail.com wrote:
>The function of the program is to output the longest word in a
sentence.

#include<stdio.H>

C is case sensitive. The correct header is stdio.h.
The filesystem might notbe case sensitive...
one platform I konw of doesn't use the '.' to separate filename from
extension so #include <stdiohdoes work too, as does #include <StdIoH>, as
that system isn't case sensiteve either.

no reason though to not use the correct stdio.h of course.
Bye, Jojo
Aug 17 '08 #9
On 2008-08-17, Joachim Schmitz <no*********@schmitz-digital.dewrote:
Barry Schwarz wrote:
>On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), su*******@gmail.com wrote:
>>The function of the program is to output the longest word in a
sentence.

#include<stdio.H>

C is case sensitive. The correct header is stdio.h.

The filesystem might notbe case sensitive...
That doesn't necessarily have anything to do with stdio.h. The C
Standard does not require headers to be actual files, though they
commonly are.

--
Andrew Poelstra ap*******@wpsoftware.com
To email me, use the above email addresss with .com set to .net
Aug 17 '08 #10
Barry Schwarz <sc******@dqel.comwrites:
On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), su*******@gmail.com wrote:
>>The function of the program is to output the longest word in a
sentence.

#include<stdio.H>

C is case sensitive. The correct header is stdio.h.
[...]

Essentially correct, but ...

The interpretation of header names, including whether they're
case-sensitive or not, is implementation-defined.

"#include <stdio.h>" is certainly the correct form, and
"#include <stdio.H>" should be avoided. My point is that the latter
won't necessarily be flagged as an error (it's likely to be accepted
on Windows, for example).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 17 '08 #11
On 2008-08-17, Barry Schwarz <sc******@dqel.comwrote:
On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), su*******@gmail.com wrote:
>>
int longest(char string[])

The name string is reserved for the implementation. It would benefit
you not to use names starting with "str".
In this case, he could use String with a capital S. (Note that for
external variables this is not generally true since linkers are not
required to be case-sensitive).

--
Andrew Poelstra ap*******@wpsoftware.com
To email me, use the above email addresss with .com set to .net
Aug 17 '08 #12
Andrew Poelstra wrote:
On 2008-08-17, Barry Schwarz <sc******@dqel.comwrote:
>On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), su*******@gmail.com wrote:
>>int longest(char string[])
The name string is reserved for the implementation. It would benefit
you not to use names starting with "str".

In this case, he could use String with a capital S. (Note that for
external variables this is not generally true since linkers are not
required to be case-sensitive).
Function names beginning with str followed by a lower case letter,
are reserved for the implementation.

I don't see anything wrong with:
int longest(char string[])

--
pete
Aug 18 '08 #13
On Sun, 17 Aug 2008 10:54:32 -0700, Barry Schwarz <sc******@dqel.com>
wrote in comp.lang.c:
On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), su*******@gmail.com wrote:
[snip]
int longest(char string[])

The name string is reserved for the implementation. It would benefit
you not to use names starting with "str".
That's overstating the case in general. In particular, the use of the
identifier "string" for the name of a function parameter is completely
valid and conforming.

To quote the standard, in paragraph 1 of 7.1.3, "Reserved
identifiers":

"All identifiers with external linkage in any of the following
subclauses (including the future library directions) are always
reserved for use as identifiers with external linkage."
....and 7.26.11, in the "Future library directions" section:

"Function names that begin with str, mem, or wcs and a lowercase
letter may be added to the declarations in the <string.hheader."

Since parameter names in function definitions have no linkage,
"string", or any other identifier beginning with "str" followed by a
lower case letter, is not reserved in this situation. Nor would it be
reserved at file scope, as long as it was restricted to internal
linkage with the static keyword.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Aug 18 '08 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6057
by: We need more power captain | last post by:
Hi, I know less than a noob, I've been asked to do some compiles in VC++ 6 without knowing too much at all. (I'm a COBOL program normally so this is all too much for me) I open VC++6, open...
1
4355
by: yanwan | last post by:
Hello I met some problems in linking a project, and hope someone can give me some advice. -----------Configuration: lighting - Win32 Release-------------------- Linking... LINK : warning...
1
6383
by: yanwan | last post by:
I met this problem in executing a c++ project in visual studio. Does anyone have suggestions to resolve "error lnk 2001"? --------------------Configuration: reconstruction - Win32...
1
3920
by: babak | last post by:
Hi everyone I'm doing a project in Microsoft embedded Visual C++ 4.0 and I get the following error when I try to compile: LINK : fatal error LNK1195: target machine 'ARM' requires...
2
6900
by: Helen | last post by:
Hi I am trying to compile a package of avi to mpeg1 C source codes But I got the link error I searched actually my VFW.h and Vfw32.lib are all in the directory what should I do thanks a lot...
1
1884
by: Helen | last post by:
Hi I am trying to compile a package of avi to mpeg1 C source codes by Visual C++ 6.0. But I got the link error --------------------Configuration: AviMp1 - Win32 Debug--------------------...
2
5151
by: jpeters | last post by:
Just installed Service Pack 5 for Visual C++ 6.0. Now I'm getting an error when linking as follows: inking... LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16...
1
7277
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error:...
3
4934
by: phobia1 | last post by:
Hi once again. We have just changed our ISP and things that worked fine now do not, Obviously its in the differences of MYSQL and PHP versions. Have fixed most of the problems but this UPDATE...
0
7204
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
7091
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...
0
7342
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
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.