-11

The 'ask question' page on Stack Overflow gives me an error with the indentation in my code. I'm putting my code in this question in search for a solution.

The error message is

Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.

The question I'm trying to submit:


Hello, I make diverse option of fuction thats converts a minor to a major capital...

But I have very a lot of problems when I diverge the types of input and comparation, because appear. The casting isn't possible or a way that realize is wrong . For example in function X_toupper2() , she realize a infinite cycle, why ..(the compiler don't realize scanf)? I am using the geany and realize a toggle point/breakpoints but I think that is only valid as markup.. and in Eclipse on the project in C is emitted a message that not possible compile in debug mode. geany progr. in C - eclipse [tutorial_breakpoints][3]

include

int sum(int arg1,int arg2) { return (arg1 + arg2); } int soma(float arg1,float arg2) { int res; res = (int) arg1 + arg2; return res; } int dobro(int d) { return 2*d; } int max (int e, int f) { if (e > f) return e; else return f; } void prog7(int a,int b)

{ printf(" 1º %d\n",max(a,b)); puts("Digite 2 numbers"); scanf("%d %d",&a,&b);

// vai anular os valores atribuidados antes!

printf("A soma será:%d\n",soma(a,b));
printf("O dobro de y é:%d\n",dobro(b));
printf("Last   %d\n",max(a,b));
}

int x_toupper_(char letra) { int i; for (i=0/* puts("Let's Go .. tenta novamente*/;;i++) { if(!(letra<121 && letra>=97)) { puts("Tenta de novo ..."); scanf("%c",&letra); continue; // passa à frente... } else letra=(int) letra-32; printf ("O que queres é:\n %c",letra); break;

    }
printf("\nÁ %dª tentativa consegui-mos arrancar ...\n",i);
return 0;
}

void X_toupper() { char c; int j='A' - 'a'; puts("Digite a letra pretendida"); scanf("%c",&c); c = (int) c; printf("%d",c); printf("%d",(int) c); printf("%c",c); while (!(c<120 && c>97)) { puts("Tenta de novo2 ..."); scanf("%c",&c); } printf("%d\n",j); c=(int) c-32; printf ("O que queres é:\n %c\n",c); } void X_toupper3() { int c; puts("Digite a letra pretendida"); scanf("%d",&c); while (!(c<120 && c>97)) { puts("Tenta de novo3 ..."); scanf("%d",&c); } c= c-32; printf ("O que queres é:\n %c\n",c); }

int main() {

x_toupper_(69);
X_toupper();
X_toupper3();

/* int x,y; puts("Digite valor para x e \nDigite valor para y"); scanf("%d%d",&x,&y); max(x,y); prog7(x,y); printf("%d\n",max(x,y)); */

//printf("%d\n%d\n",sum(4,9),soma(3.3,5.21));

return 0;
  • 11
    Does your code look right to you? Does it look properly formatted? – Oded Nov 8 '15 at 18:11
  • 2
    Because, well, it's not properly formatted? – nicael Nov 8 '15 at 19:18
  • 3
    @Peter that edit completely changed the question! The OP is showing us his badly formatted code and saying that it doesn't work. So it's supposed to be like that – ᔕᖺᘎᕊ Nov 8 '15 at 20:29
6

When you type code in a question you need to indent it by four spaces, just like the message says to you. If you don't, the punctuation gets interpreted as formatting instructions. Look at the first line, #include <stdio.h>.

When you don't indent it, it comes out like this

include

The # is interpreted as "this is a heading" and the contents of the < and > disappear because it's assumed to be some sort of HTML tag.

When you put 4 spaces at the start of each line, it comes out like this:

#include <stdio.h>

And that's what you want.

It can be super tedious putting in the four spaces line by line, so you can use the little toolbar in the question editor. Select the lines of code and click the button that looks like {} and the code will be indented for you.

Try it - not on this question, but back where you were trying to ask before.

  • 1
    +1 but might be worth linking to the formatting sandbox so OP can mess around in it :) – ᔕᖺᘎᕊ Nov 8 '15 at 20:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .