How can I print integers as a string in C++ using character arrays?

  • Context: Comp Sci 
  • Thread starter Thread starter sdoug041
  • Start date Start date
  • Tags Tags
    Arrays C++ Printing
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
8 replies · 4K views
sdoug041
Messages
25
Reaction score
0

Homework Statement



I have a bunch of integers stored in a character array, and I am trying to print the integers as characters. I can print them as characters when I use %c in the print statement, but the problem is I need to print them as a string. My program crashes when I attempt to use the %s in the print statement. Can anyone help me out?


Homework Equations





The Attempt at a Solution

 
Physics news on Phys.org
Sorry I should have been more specific; the assignment I am working on is to develop a program that can cipher and decipher vigener's/ceaser ciphering.

My function I have created receives three references of character arrays. One array stores the key word, one array stores the secret message, and one array is empty, waiting to be filled with the encrypted text; which is the job of this function.

I had to convert the characters stored in the two arrays into their corresponding integer values in order to develop the encrypted values (using a mathematical equation) which should then be stored into the empty character array. All the values in this array correspond to letter characters which should spell out the encrypted text.

The only problem I have is being able to convert these values back to their corresponding letter characters. I hope this clears up the problem.
 
We help much unless we see the code you used.
 
Help us help you help us help us all.