Back to Off Topic

IT PROGRAMMING C++

about 10 years

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; }

about 10 years
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;
}
deletedabout 10 years
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<
about 10 years
and it's not working ;(
about 10 years
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<
about 10 years
I remember doing this in Java but I don't feel like digging through those files.
about 10 years
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.
about 10 years
that mistake occurred due to skype c/p (a) = angel
about 10 years
it takes like 1 minute I think I can't see it...and I wanted to say strlen(a)
about 10 years

jWizard says

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?
about 10 years
This would be a good topic for Gary.
deletedabout 10 years
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.
about 10 years
for example if my string is

dog Cat *roughness

the output => Dog Cat *Roughness
deletedabout 10 years
Can you provide example input/output of your program?
about 10 years
I need to change the lower case to upper case basically