main.cppToUpper ToLower не работает, помогает то, что случилось с моим кодом
#include <iostream>
#include "Module2.h"
int main()
{
std::cout<<"This is a test of Module2.h"<<std::endl;
std::cout<<UCase("This is a test of UCase")<<std::endl;
std::cout<<LCase("This is a test of LCase")<<std::endl;
system("pause");
return 0;
}
Module2.h
#include <iostream>
#include "Module2.h"
int main()
{
std::cout<<"This is a test of Module2.h"<<std::endl;
std::cout<<UCase("This is a test of UCase")<<std::endl;
std::cout<<LCase("This is a test of LCase")<<std::endl;
system("pause");
return 0;
}
Module2.cpp
///////////////////////////////////////////////////
//Module : Module2.cpp
//
//Purpose : Shows the usage of modular functions
///////////////////////////////////////////////////
#include "Module2.h"
///////////////////////////////////////////////////
//UCase()
char *UCase(char *str)
{
//convert each char in the string to uppercase
//
int len = strlen(str);
for (int i ; i < len ; i++)
{
std::cout<<"In UCase"<<std::endl;
str[i]=toupper(str[i]);
}
return str;
}
///////////////////////////////////////////////////
//LCase()
char *LCase(char *str)
{
//convert each char in the string to uppercase
//
int len = strlen(str);
for (int i ; i < len ; i++)
{
std::cout<<"In LCase"<<std::endl;
str[i]=tolower(str[i]);
}
return str;
}
Когда я запускаю его там никаких предупреждений или ошибок. Но это не верхняя и нижняя строка. Я думал, что мои петли ошибочны, но это кажется правильным. Что не так с моим кодом.
Если это скомпилировано без предупреждений, вам нужно включить дополнительные предупреждения. –
Вы уверены, что ваш «Module2.h» действительно то, что вы разместили, идентично «main.cpp»? – Deduplicator
У вас есть две основные функции(). Разрешается только одно: здесь должна запускаться программа –