-1

I create this file over and over and cant seem to see why I'm getting this error. I tried going to the line where the code is but the format seem correct I may just need another set of eyes .

#include <iostream>
#include <string>
#include <cstring>

using namespace std;

void readString(char*, int);
void changeToUppercase(char*, int);
void displayStringInUppercase(char*, int);

int main()
{
    int arraySize;
    char* characterArray;

    cout << "Enter the size of dynamic array: ";
    cin >> arraySize;

    characterArray = new char[arraySize];

    readString(characterArray, arraySize);

    changeToUppercase(characterArray, arraySize);

    displayStringInUppercase(characterArray, arraySize);

    delete [] characterArray;

    system ("pause");
    return 0;
}

void changeToUppercase(char* characterArray, int arraySize)
{
    for(int i = 0; i < arraySize; i++)
        characterArray[i] = toupper(characterArray[i]);
}

void displayStringInUppercase(char* characterArray, int arraySize)
{
    cout << "\nThestring inupper case letters: ";

    for(int i = 0; i < arraySize; i++)
        characterArray[i] = toupper(characterArray[i]);
}

This is the error codes that keep popping up:

error LNK2019: unresolved external symbol "void __cdecl readString(char *,int)" (?readString@@YAXPADH@Z) referenced in function _main

fatal error LNK1120: 1 unresolved externals
Darth Hunterix
  • 1,484
  • 5
  • 27
  • 31
Kayla
  • 9
  • 1

2 Answers2

2

You use a forward declaration: void readString(char*, int); but then never actually define this function.

Define your readString function later in your code like...

void readString(char* str, int a)
{
    // do stuff
}
bpgeck
  • 1,592
  • 1
  • 14
  • 32
2

You are missing the readString function. You have a forward declaration that satisfies the compiler here

void readString(char*, int);

But no actual implementation of the function to satisfy the linker when it tries to put your program together. You need something along the lines of

void readString(char* characterArray, int arraySize)
{
    // do stuff here
}
user4581301
  • 33,082
  • 7
  • 33
  • 54