Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Help with a c++ code

/*Extra 10 b*/

#include <stdio.h>

#include <string.h>

main()

{

char f[80];

int i,c=0;

scanf("%[^\n]",f);

for (i=0;i<strlen(f);++i)

if (f[i]=='m'||f[i]=='M') ++c;

printf("%i",c);

}

it says

“C++ requires a type specifier for all declarations whilst defining methods”

help please

Posted on Feb 6, 2016 4:48 AM

Reply
Question marked as Best reply

Posted on Feb 6, 2016 10:37 AM

The best place for assistance with C++ would be C++ forums.


The issue is your function declaration does not have a return type and main() should return an integer.


Try:


int main()

{

/* code here */

return 0;

}



Edit: You're also using C headers instead of C++.

1 reply

Help with a c++ code

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.