Wow, I found something!!!! Woohooo!
You need to change
char* c
to
char c
This gets rid of your compile errors. Now, I don't think the code is working right for you. For me to input a character into the stream, I have to hit return, which seems to trip your exit logic.
I think you need to rethink that part of the design.
I am too fried, and I hate characters, and I am not the sharpest knife in this drawer anyway.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, my name is Franjo and I have a little problem using Dev-C++. Some programs don't work. For example:
#include <iostream.h>
#include <stdlib.h>
#include <cstring>
using namespace std;
int main()
{
char* c;
while(cin.get(c))
{
if(c >= 'a' && c <= 'z')c+='A'-'a';//capitalize c
cout.put(c);
if(c=='\n')break;
}
system("PAUSE");
return 0;
}
After compiling, I get a whole bunch of errors. Do you know what's wrong? Greetings, Franjo
Wow, I found something!!!! Woohooo!
You need to change
char* c
to
char c
This gets rid of your compile errors. Now, I don't think the code is working right for you. For me to input a character into the stream, I have to hit return, which seems to trip your exit logic.
I think you need to rethink that part of the design.
I am too fried, and I hate characters, and I am not the sharpest knife in this drawer anyway.
Wayne
#include <iostream.h>
#include <stdlib.h>
#include <cstring>
#include <conio.h>
using namespace std;
int main()
{
char c;
while(true)
{
c = getch();
if(c >= 'a' && c <= 'z')
{
c+='A'-'a';//capitalize c
cout.put(c);
}
else //if c != any known letter a-z
break;
}
system("PAUSE");
return 0;
}
This works for me, but I do not know what you are trying to do. To capitalize though, I would include ctype.h and use the toupper command.
eg:
c = toupper(c);
cout.put(c) //instead of if(c >= 'a' && c <= 'z')
{
c+='A'-'a';//capitalize c
cout.put(c);
}
Have fun.
Curtis