I am currently learning C++ and I am in the process of configuring Emacs as my C++ IDE. I am reading a PDF guide and copying code into my Emacs buffer. However upon pasting the code the formatting is incorrect which is what I expected.
For example:
int count_x(char
∗
p, char x)
//
count the number of occurrences of x in p[]
//
p is assumed to point to a zero-ter minated array of char (or to nothing)
{
if (p==nullptr) return 0;
int count = 0;
for (;
∗
p!=0; ++p)
if (
∗
p==x)
++count;
return count;
}
How can I reformat the above code to look like this:
int count_x(char* p, char x)
// count the number of occurrences of x in p[]
// p is assumed to point to a zero-terminated array of char (or to nothing)
{
if(p==nullptr) return 0;
int count = 0;
for(; *p!=0; ++p)
if(*p==x)
++count;
return count;
}
Thanks!