0

So Im trying to make the cipher uppercase the cipher. I think that'll save a lot of hassle with if isupper else blah blah.

So I made a function

int uppercase(string a); int uppercase(string a) { for (int i = 0, n = strlen(a); i < n; i++) { toupper(a[i]); } 

Then I declared a function

string c = uppercase(argv[1]); 

Then cycle through c[j], while making a loop like this

for (int i = 0, int j = 0, n = strlen(s); i < n; i++, j++) 

So 2 questions here. Im getting an error like this

warning: incompatible integer to pointer conversion initializing 'string' (aka 'char *') with an expression of type 'int' [-Wint-conversion] string c = uppercase(argv[1]); 

How would I fix this

Question 2, is it even possible to have two integers looping like I did above? as in i++ j++

1 Answer 1

1

Look at what this line of code does:

string c = uppercase(argv[1]); 

It declares c as a string, or more specifically, a pointer to a character string. The function uppercase() that you declared retruns an integer. This statement is trying to assign an integer to a pointer. That just doesn't work.

And yes, it is possible to increment two vars in a for loop.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1
  • Would this work then void uppercase(char a[]) { for (int i = 0, n = strlen(a); i < n; i++) { toupper(a[i]); } Then call upon it like this : string k = argv[1]; uppercase(k); There is still a bug somewhere not sure if this is the issue. Commented Jul 2, 2016 at 14:42

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.