Re: [Dev-C++] Please help me...why doesn't the code compile?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Vassili <v.v...@bt...> - 2001-08-11 16:00:42
|
If your going to use pointers and arrays, always have an address to store
data, ditto for char, int, float,...,etc.
try using something like:-
#include <iostream.h>
#include "module1.h"
void main()
{
// Initialised plus somewhere to store data
char str1[] = "This is a test of UCase";
char str2[] = "This is a test of LCase";
// Pass the address of strings and display the
// modified data, which is the returned address
cout << "This is a test\n"
<< UCase(str1) << endl
<< LCase(str2) << endl;
}
----- Original Message -----
From: "Jose Samonte" <dyo...@ho...>
To: <dev...@li...>
Sent: Saturday, August 11, 2001 12:56 AM
Subject: [Dev-C++] Please help me...why doesn't the code compile?
> Please help me anyone... :-)
> There are actually three files here; main.cpp, module1.cpp, and main.cpp.
> I'm trying to separate the function prototypes into a header file, and put
> the function body in a source file, since the function is generic enough
to
> be used in many programs, and I want to make it into a module, but it
> doesn't compile... :-(
> THANK YOU in advance!!!
>
>
>
> //////////////////////////////////////////////////////
> // Module : main.cpp
> //
> // Purpose : Shows the usage of modular functions
> //////////////////////////////////////////////////////
>
> #include <iostream.h>
> #include "module1.h"
>
> void main()
> {
> cout << "This is a test\n";
> cout << UCase("This is a test of UCase\n");
> cout << LCase("This is a test of LCase\n");
> }
>
> //////////////////////////////////////////////////////
> // Module : module1.cpp
> //
> // Purpose : Shows the usage of modular functions
> //////////////////////////////////////////////////////
>
> #include "module1.h"
>
> //////////////////////////////////////////////////////
> // UCase()
>
> char* UCase(char *str)
> {
> // Convert each char in the string to uppercase
> //
> int len = strlen(str);
> for (int i = 0; i < len; i++)
> str[i] = toupper(str[i]);
>
> return str;
> }
>
> //////////////////////////////////////////////////////
> // LCase()
>
> char* LCase(char *str)
> {
> // Convert each char in the string to lowercase
> //
> int len = strlen(str);
> for (int i = 0; i < len; i++)
> str[i] = tolower(str[i]);
>
> return str;
> }
>
> //////////////////////////////////////////////////////
> // Module : module1.h
> //
> // Purpose : Interface for module1.cpp
> //////////////////////////////////////////////////////
>
> #ifndef __MODULE1_H__
> #define __MODULE1_H__
>
> #include <stdlib.h>
> #include <ctype.h>
> #include <string.h>
>
> // Function prototypes
> //
> extern char* LCase(char *str);
> extern char* UCase(char *str);
>
> #endif //__MODULE1_H__
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|