• Register
1 vote
14 views

Problem:

How to run a program and print in c++. I hope you guys are not laughing at my question. Yeah, I am a newly born programmer laugh

#include <string>
string someString("This is a string.");
printf("%s\n", someString);

I tried this but it’s not working.

12 7 7
15,250 points

1 Answer

1 vote

Solution:

Try 

#include <iostream>
std::cout << someString << "\n";

OR

printf("%s\n",someString.c_str());

 

13 9 6
94,240 points

Related questions

0 votes
1 answer 7 views
7 views
The program works up to 3 for but from the fourth the search for the minor / s and the major / s begins, which I managed, but if the value is repeated (which is the lowest or highest ), thus having 2 (or more) minors or majors, it only prints the one below the entered ones. So the question is ... << << "is the one with the fewest days left" << "(" << less << ")" << endl; cout << endl; return 0; }
asked Aug 14 game 4.6k points
0 votes
1 answer 7 views
7 views
I have a program, I would like what is printed to be Uppercase regardless of what it receives (MAYUS or minus). It is almost ready, I just need to print in capital letters. I print my void in the main, but I want it to print my void in UPPERCASE. Example Hello World. (with offset 3) KROD PXQGR #include ... if (secret [i] == alphabet [j] && j <78) { secret [i] = alphabet [j + n]; j = 52; } } } } }
asked Aug 10 game 4.6k points
0 votes
1 answer 10 views
10 views
Well, this is a vector that tries to capture the letters, that is, each element of the vector is a letter that is being typed, however, in the end I don't know how to print the letters before typed. This is just one function. char enterChar () {      char character = '';      int i = 0;      if ...        cout << "element" << i << "is:" << phrase [i] << endl;      }      else          return 0; }
asked Aug 15 game 4.6k points
1 vote
1 answer 23 views
23 views
Problem: Hello good people, I am a new student of programming. One of my friends inspired me to learning programming and I took up the C++ language. My friend said it is easy to grab and I accept his words. Anyway, I am in the chapter of the array now. I ... printing in a C++ program. Please, write me a code that prints array and keep your program as easier as possible. Thanks for your concern.
asked Apr 19 Gavin 15.3k points
0 votes
1 answer 3 views
3 views asked 7 hours ago Shaad Sh 220 points