GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 30-Apr-2007, 07:23
silverneon silverneon is offline
New Member
 
Join Date: Mar 2007
Posts: 12
silverneon is on a distinguished road

What do these errors mean?


Hi, I'm doing a small program. I'm supposed to write a function named trimfrnt() that deletes all leading blanks from a C-string. Write the function using pointers. The function returns nothing. When I run the program I get these errors.
CPP / C++ / C Code:
#include <iostream> 
using namespace std;

void trimfrnt(char *strng)		
{
  int i = 0;				
  int len = 0;  
  len = strlen(strng);   
  i = len - 1;
  while (*(strng + i) && *(strng + i) == ' ')
  i--;
  len = i + 1; 
  *(strng + len) = '\0';
  return;
}
CPP / C++ / C Code:
Undefined                       first referenced
 symbol                             in file
main                                /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.3.6/crt1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
Anyone know what this means and how to fix it?
  #2  
Old 30-Apr-2007, 07:51
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,701
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: What do these errors mean?


Quote:
Originally Posted by silverneon
Hi, I'm doing a small program. I'm supposed to write a function named trimfrnt() that deletes all leading blanks from a C-string. Write the function using pointers. The function returns nothing. When I run the program I get these errors.

Code:
Undefined first referenced symbol in file main
Anyone know what this means and how to fix it?

It means that you don't have a main() function.

Fix it by writing a main() function.

In particular: To test your function write a main() function that calls trmfront() with an argument that is a C-string with leading spaces.

Regards,

Dave
  #3  
Old 30-Apr-2007, 08:10
Lurch Lurch is offline
New Member
 
Join Date: Jun 2006
Location: Timisoara, Romania
Posts: 6
Lurch is on a distinguished road

Re: What do these errors mean?


The function you wrote trims the trailing spaces from the C string, not the leading ones, although the name (and also your description of the function) suggests otherwise.
Does the function really do what you intended ?

PS: Perhaps is not necessary to put a return statement exactly at the end of your function, as it returns void.

Best regards,
Lurch.
  #4  
Old 30-Apr-2007, 14:27
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: What do these errors mean?


Quote:
Originally Posted by Lurch
PS: Perhaps is not necessary to put a return statement exactly at the end of your function, as it returns void.

Best regards,
Lurch.
Not necessary but recommended anyway. It's good practice not to rely on default actions when it doesn't take anything to be specific.

Gomez
__________________

Age is unimportant -- except in cheese
 
 

Recent GIDBlogToyota - 2008 September Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Link Errors jdbrine C++ Forum 10 18-Jun-2006 14:55
Compile Errors due to Default Parameters jdbrine C++ Forum 1 17-Jun-2006 14:45
getting following errors in vc++ angel188 MS Visual C++ / MFC Forum 4 13-Jun-2006 14:10
syntax errors in document coder MS Visual C++ / MFC Forum 0 11-Mar-2006 04:12
In Need of Some Serious Help...compiling errors [C++] needcishelp C++ Forum 25 21-Dec-2005 01:26

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:47.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.