IT PROGRAMMING C++

MisterEpicMafiaover 11 years ago

hey I have to turn every letter from a string in capital letter. I don't know how many words there are nor if the first letter is capital or not. this algorithm is not working properly?? Any ideas why? Help please

include <iostream>

include <string.h>

include <fstream>

include <ctype.h>

using namespace std;

ifstream f("atestat.in");

ofstream g("atestat.out");

int main()

{unsigned int n,i,val=32;

char a[50];

f.getline(a,50);

n=strlen(angel);

//a if(a[1]>='a' && a[1]<='z')

cout&lt;&lt;a[1]-val;

else cout&lt;&lt;a[1];

for(i=2;i<=strlen(a);i++)

if((isalpha(a[i-1])==0)&& isalpha(a[i])==1)

cout<<a[i]-val;

else cout<<a[i];

f.close(); g.close(); return 0; }

Simsover 11 years agoedited
i'm not sure if you're supposed to be using files or not, but here you go. you can edit it if you are

#include ****
#include ****
#include ****
#include ****

using namespace std;

int main ()
{
int i=0;
char a[50];
char c;
cin.getline(a,50);
while (a[i])
{
c=a[i];
putchar (toupper(c));
i++;
}
system("PAUSE");
return 0;
}
deleteddeletedover 11 years agoedited
I haven't worked with C++ for a while so I'm kind of rusty on the syntax.

int main(){

char a[50]; //Assuming 50 is max length

f.getline(a,50);

int length = strlen(a);

for(int i=0; i= 'a' && a[i]<='z' ? a[i]-32 : a[i];
cout<
MisterEpicMafiaover 11 years ago
and it's not working ;(
MisterEpicMafiaover 11 years ago
using namespace std;

ifstream f("atestat.in");

ofstream g("atestat.out");

int main()

{unsigned int n,i,val=32;

char a[50];

f.getline(a,50);

n=strlen(a);

//a if(a[1]>='a' && a[1]<='z')

cout<<a[1]-val;

else cout<<a[1];
for(i=2;i<=strlen(a);i++)

if((isalpha(a[i-1])==0)&& isalpha(a[i])==1)

cout<
UniversalStudiosover 11 years ago
I remember doing this in Java but I don't feel like digging through those files.
UniversalStudiosover 11 years ago
I'm confused. You should have the commands you need to input a word and receive the desired capitalization. Just find out the code you need to output and work from there.
MisterEpicMafiaover 11 years ago
that mistake occurred due to skype c/p (a) = angel
MisterEpicMafiaover 11 years agoedited
it takes like 1 minute I think I can't see it...and I wanted to say strlen(a)
MisterEpicMafiaover 11 years ago
jWizard
What is strlen(angel)?? You don't have an angel variable.

The process of converting each letter should be done in a loop. I don't know why you commented out the if statement under strlen(angel).

Your bottom for loop doesn't have an opening bracket so nothing gets looped.


Hey could you please c/p the algorithm and correct the mistake?
UniversalStudiosover 11 years ago
This would be a good topic for Gary.
deleteddeletedover 11 years ago
What is strlen(angel)?? You don't have an angel variable.

The process of converting each letter should be done in a loop. I don't know why you commented out the if statement under strlen(angel).

Your bottom for loop doesn't have an opening bracket so nothing gets looped.
MisterEpicMafiaover 11 years ago
for example if my string is

dog Cat *roughness

the output => Dog Cat *Roughness
deleteddeletedover 11 years ago
Can you provide example input/output of your program?
MisterEpicMafiaover 11 years ago
I need to change the lower case to upper case basically