10 Replies - 1301 Views - Last Post: 20 February 2007 - 10:28 PM Rate Topic: -----

#1 vsrik015  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-January 07

how is it possible to print a character in one line

Posted 20 February 2007 - 01:20 PM

#include<stdio.h>
void main()
{
   char a[5]="asdhd";// after printing the character we have to delete it and display it in next line
   printf("%c",a[0]);

}

This post has been edited by vsrik015: 20 February 2007 - 01:40 PM

Is This A Good Question/Topic? 0
  • +

Replies To: how is it possible to print a character in one line

#2 dorknexus  Icon User is offline

  • or something bad...real bad.
  • member icon

Reputation: 1256
  • View blog
  • Posts: 4,618
  • Joined: 02-May 04

Re: how is it possible to print a character in one line

Posted 20 February 2007 - 01:31 PM

do you have an actual question concerning this piece of code?
Was This Post Helpful? 0
  • +
  • -

#3 vsrik015  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-January 07

Re: how is it possible to print a character in one line

Posted 20 February 2007 - 02:01 PM

View Postvsrik015, on 20 Feb, 2007 - 01:20 PM, said:

#include<stdio.h>
void main()
{
   char a[5]="asdhd";// after printing the character we have to delete it and display it in next line
   printf("%c",a[0]);

}



help

i want help anybody
Was This Post Helpful? 0
  • +
  • -

#4 vsrik015  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-January 07

Re: how is it possible to print a character in one line

Posted 20 February 2007 - 02:14 PM

how to display the character and delete it and again display in another line


it should appear like this
1. p p goes to next line
2.p

it should be like this 1,2 for understanding are line numbers
1.
2.p

nobody is helping me
even the moderator
Was This Post Helpful? 0
  • +
  • -

#5 vsrik015  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-January 07

Re: how is it possible to print a character in one line

Posted 20 February 2007 - 02:29 PM

if anybody knows it please do reply
Was This Post Helpful? 0
  • +
  • -

#6 vsrik015  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-January 07

Re: how is it possible to print a character in one line

Posted 20 February 2007 - 02:38 PM

the character should go from one line to another line .
The preceding line character should not appear when the letter in on next line.
And this should be done from top to bottom of screen.
Was This Post Helpful? 0
  • +
  • -

#7 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: how is it possible to print a character in one line

Posted 20 February 2007 - 02:41 PM

I think we are having trouble knowing what you need to do.

To do as you asked "display a char, delete it, then display it in another line" I am going to assume you mean something like a scroll up might do.

What environment are you programing in? If you are doing windows console IO I don't think this will work as you don't have control over something once it is printed. If you are writing a DOS app then you can use something like conio.h (borland c++). If you are working inside a window well then of couse you can do it.

I understand it is frustrating but we need to see the code you are working with to help.
Was This Post Helpful? 0
  • +
  • -

#8 vsrik015  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-January 07

Re: how is it possible to print a character in one line

Posted 20 February 2007 - 02:47 PM

this should be done using c language
Was This Post Helpful? 0
  • +
  • -

#9 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: how is it possible to print a character in one line

Posted 20 February 2007 - 02:50 PM

With stdio.h you can not unprint a char. To do this you need more control. If you were just printing to a monitor in a text mode you could use a library that has a function like puttext(col, row, text) or you can write directly to the video buffer.

functions like printf() are kind of like writing to a file. Once it is written in you have to start at the top to change anything.

#include<stdio.h>
void main()
{
   char a[5]="asdhd";// after printing the character we have to delete it and display it in next line
   printf("%c",a[0]);
   printf("\n%c",a[0]);

}
Best I can offer at this point.

What is the end result of this? To print the chars like this:
d
h
d
s
a

So that "a" is the last thing printed?

This post has been edited by NickDMax: 20 February 2007 - 02:55 PM

Was This Post Helpful? 0
  • +
  • -

#10 vsrik015  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-January 07

Re: how is it possible to print a character in one line

Posted 20 February 2007 - 03:01 PM

#include<stdio.h>
void main()
{
   char a[5]="asdhd"; 
   printf("%c",a[0]);// how to display the character in next line ,by deleting the 
							   last line's character . I am not getting any idea.
							   someone can give any clue 

}


any predefined function which can help for this


NickDMax can u help me
Was This Post Helpful? 0
  • +
  • -

#11 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: how is it possible to print a character in one line

Posted 20 February 2007 - 10:28 PM

Since you are so insistant I will help as I can.

There are two ways I see of approching this problem:

#1 Write the program in windows. You would place you output into a container like a textbox and then just modify the text as needed. basicly you would just add a "/n" to the begining of the string that you print.

#2 Forget windows and go DOS (if you are in UNIX/LINUX see another programmer):

To the best of my knowledge the following is only valid under Borland Turbo C++ 3.0 (which I *think* you can download for free) running in a full screen DOS process.

you will use Borland's version of conio which has a bunch of functions that are not standard to C.

The function you need is gotoxy(int x, int y) this let you control the position of the cursor with (0,0) being the top left corner (79,0) the top right corner, (0,24) the bottom left, (79,24) the bottom right. Assuming you are in mode 80x25 char text mode.

#include <conio.h>

void printAt(int iRow, int iCol, char *sText);
void putchAt(int iRow, int iCol, char ch);
void clearRow(int iRow);

void main()
{
	char *sTest="abcdef";
	putchAt(1,1,sTest[0]);
	printAt(25,1, "Press any key to continue");
	getch();
	clearRow(1);
	putchAt(2,1,sTest[0]);
	return;
}

//Prints a zero terminated string at (col, row)
void printAt(int iRow, int iCol, char *sText)
{
	gotoxy(iCol - 1, iRow -1);
	cprintf(sText);
}

//Prints a single char at a given coordinate
void putchAt(int iRow, int iCol, char ch)
{
	gotoxy(iCol - 1, iRow -1);
	putch(ch);
}

void clearRow(int iRow)
{
	char ch = 32;
	int i;
	for (i=0; i<79; i++)
	{
		putchAt(iRow, i, ch);
	}
}


I don't think that this program will do you much good as it really is out-of-date. I would recommend you take another look at what you are trying to do. Look at the big picture. Why do you need to do this one little thing? Is there another way to produce your output without doing this?

One thing a programmer need to do is learn that there are LOTS of ways to solve a problem.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1