C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
"c" compiler error message... Posted by demet8 on 1 Jul 2012 at 12:59 PM
why is the compiler giving me an error of undefined reference to
'findChar' ? also how can I display all the characters entered?

Here's my code:

#include <stdio.h>
#include <stdlib.h>


#define SIZE 100

int findChar(char array[], char c);
int findCount(char array[], int c);

int main()
{
int count;
int position;
int frequency;
char ch, array[SIZE];

printf("Enter a character : \n");

for(count = 0; ((array[count] = getchar()) != '\n'); ++count);
array[count+1] = '\0';

printf("Search a character : \n");

ch = getchar();
position = findchar(array, ch);
frequency = findCount(array, ch);

if(position == -1)
{
printf("Not found! \n");
}
else
{
printf("%c is found in the position of %d", ch, position+1);
printf("The count of %c is %d \n", ch, frequency);
}
system("pause");
return 0;
}

int findChar(char array[], char c)
{
int i, j;
for(i = 0; array[i] != '\0'; i++)
{
if(array[i] == c)
{
return i;
}
}
return -1;
}

int findCount(char array[], int c)
{
int i;
int j = 0;

for(i = 0; array[i] != '\0'; i++)
{
if(array[i] == c)
{
j++;
}
}
return j;
}




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.