473,382 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

what does"%c" mean in c and how can i convert it to c++????

12
pleaaeaeaeaese quick before wednesday


what does"%c" mean in c and how can i convert it to c++????
Jan 6 '07 #1
3 12827
Banfa
9,065 Expert Mod 8TB
I assume you mean in a printf statement. In such a location it means that the data has a value that is a printable character and should be output as a character rather than a number, this code should illustrate it

Expand|Select|Wrap|Line Numbers
  1. int main(int argc, char **argp)
  2. {
  3.     char c = 'A';  /* Assign c the value of the character constant 'A' */
  4.  
  5.     /* Print c as a character and as a number */
  6.     printf("'%c' = %d\n", c, c);
  7.  
  8.     return 0;
  9. }
  10.  
The variable c is output via printf as both a number and a printable character.

The C++ equivalent is

Expand|Select|Wrap|Line Numbers
  1. #include "iostream"
  2.  
  3. using namespace std;
  4.  
  5. int main(int argc, char **argp)
  6. {
  7.     char c = 'A';  /* Assign c the value of the character constant 'A' */
  8.  
  9.     cout << "'" << c << "' = " << (int)c << endl;
  10.  
  11.     return 0;
  12. }
  13.  
Jan 7 '07 #2
willakawill
1,646 1GB
pleaaeaeaeaese quick before wednesday


what does"%c" mean in c and how can i convert it to c++????
This can also be used in c++

Expand|Select|Wrap|Line Numbers
  1. char c = 'A'
  2. char message[20];
  3.  
  4. sprintf_s(message, 20, "c char: %c\nc int: %d", c, c);
  5. cout << message << endl;
Jan 7 '07 #3
baroon
12
thaaaaanxxxxxxxxxxxxx very much my friend for help but i hahe something also to help
i have programe and i need someone to change it from c to c++ .please i should finish it befor tuesday please,,,,,,,,this is the programe


__________________________________________________ ______________

/* Problem 0: Write a paragraph read from a file to the screen
in a justified format, paragraph should end with . */

/* Include libraries */
#include <stdio.h>
#include <string.h>


int i,j;
char temp1[1000];
FILE *in;

/* Excution Of Main Program Starts Here */
int main ()
{

/* Open and Read from input file */
in = fopen ("indata.dat","r");
if (in == NULL)
{

/* In case the file name does not exist, the following error
/* message will be displayed */

printf("Error : Couldn't open file indata.dat for reading...\n");
printf("Error : File does not exist... \n");
return 0;
}
else
{


/* Reading the pharagraph from file and print it in a justified mode */


printf("\n The Justified Pharagraph is >> \n\n");
fscanf(in,"%[^.].",&temp1);


j=0;
while (j<500)
{
label_start:
printf("\n ");
for (i=j+1; i<=j+60; i++)
{
if (temp1[i] == '.')
goto label_end;

if (temp1[i] == '\n')
{
j=i;
goto label_start;
}
printf("%c",temp1[i]);
}
j=j+60;
}

label_end:
fclose(in);

printf("\n---------------------------------------------------------\n");
printf(" Thank You For Using My Program \n");
printf(" Have A Nice Day \n");
printf("---------------------------------------------------------\n");
getchar();
return 1;
}}

__________________________________________________ ____
the program take the paragraph which want to justified from (txt.) for example
the paragraph is ( This is program homework to be done in C++ language for the Clanguage course,it is realy interesting course which I have enjoied it alot :)
I like programing languages...) . and the out put should be in the black screen :)
Jan 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: lkrubner | last post by:
I want to give users the power to edit files from an easy interface, so I create a form and a PHP script called "fileUpdate". It does a reasonable about of error checking and prints out some...
2
by: Scott | last post by:
MySQL calls 4.1.5 a "Gamma" release. What does that mean?
5
by: Steven T. Hatton | last post by:
I've seen people here write that C++ doesn't support modules. What does that mean? 'Module' is a very nebulous term in my book. It probably means something quite different to me than what it does...
4
by: Luke Wu | last post by:
I am just wondering what the following terms usually mean: 1) "Standard C" 2) "K&R C" 3) "ANSI C" I am pretty sure "ANSI C" usually refers to the C89 standard, but what
4
by: chandanlinster | last post by:
hello everybody, as i was going through the "printf" man page, i came across this statement. printf("%*d", width, num); what does "*" mean?
12
by: hn.ft.pris | last post by:
I know int *p mean an array of pointers to int, but I meet int (*p) which is confusing. What does it mean and how to use it? Thanks for help.
4
by: lander | last post by:
I've read the page life cycle thing in msdn, still, i'm getting a bit confused of thinking how all the things are going under the hood... I know that when page loading, that the controls'...
4
by: Lightmage | last post by:
Hello all, I am using C++ to convert a certain file into an XML file. During the conversion the program does some arithmetic operations on the information that is then outputted in xml format. ...
4
by: david.karr | last post by:
I'm a CSS newbie, but I was browsing through the css files in the YUI library, and I noticed the following line: body {font:13px/1.231 arial,helvetica,clean,sans-serif;*font-...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.