Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do you make ":" aligns? like on a full straight line going down

+7 votes
asked Oct 15, 2025 by Braven Prajna Alova (190 points)
reshown Oct 15, 2025 by Admin
current situation

name:

age:

wanted

name    :

age       :

1 Answer

0 votes
answered Oct 15, 2025 by Peter Minarik (101,420 points)
edited Oct 16, 2025 by Peter Minarik

What language do you use?

You need to insert padding to align your text.

Many languages have built-in features. For instance, C's printf() has the format specifiers. See the examples there or this short one below.

For left justification, I used a negative number (-10), then the text to be displayed, and then the value that belongs to the texts.

#include <stdio.h>

int main()
{
    printf("%-10s : %s\n", "name", "John Doe");
    printf("%-10s : %d\n", "age", 64);
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...