i have a new problem with another exercise. It states like this:
Imagine that we have a program that requires the informations of the user. for this purpose write a function Insert, that will look after the users informations. Because the function has to be general, its parameter should be a string, that has to be printed on the screen. If the user didn't write any informations the function returns NULL (char *Insert( char* )). The usage of the function is the following:
Code:
char *name;
name = Insert("Write your name . . .");
// . . .
delete name
My code looks like this:
Code:
//POGL8_vaja2.cpp
#include <iostream>
using namespace std;
char clear_array(char *info)
{
int i;
for (i==0; i < 200; i++)
{
info[i] = 0;
}
}
char *feelIn(char *info)
{
int count_char;
char *point = info;
char *memory = new char[200];
while (*point != '\0')
{
point++;
count_char++;
}
memory[count_char];
memory = info;
info = memory;
*point = *memory;
if (count_char > 0) return memory;
else return '\0';
}
int main()
{
char *info = new char[200];
clear_array(info);
cout << "Write down your name!" << endl;
cin >> info;
char *space = feelIn(info);
cout << "Your name is " << space << endl;
delete info;
}
the second error is that if i write a name for instance Mark
the program returns MarkM.
I don't know what i did wrong thats why i am asking for your help.
thanks a lot
best regards,
BoSCHoW.

