• Register
1 vote
17 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

Please log in or register to answer this question.

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 9 views
9 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, 2020 game 4.6k points
0 votes
1 answer 10 views
10 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, 2020 game 4.6k points
0 votes
1 answer 15 views
15 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, 2020 game 4.6k points
0 votes
1 answer 13 views
13 views
Problem: My code asks for data and fills it to the array. Then check if they are even. And it should print the data which is even. The data filling if you do it correctly. But at the time of printing I only get this - The number 0 in position [0] is even #include <iostream> using namespace std; int ... { cout << "The number" << * p ++ << "in position [" << i << "] is even \ n"; } } return 0; }
asked Dec 5, 2020 sasha 5.3k points
1 vote
1 answer 26 views
26 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, 2020 Gavin 15.3k points
0 votes
1 answer 4 views
4 views
Problem: This c++ code prints out the following prime numbers: 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97. But I don't think that's the way my book wants it to be written. It mentions something about square root of a number. So I did try ... <sqrt(i); j++) but it did not give me the result I needed. How would I need to change this code to the way my book wants it to be?
asked Dec 13, 2020 Mashhoodch 5.7k points
0 votes
1 answer 19 views
19 views
Can I do it with System.out.print?
asked Jan 3 TeamScript 9.9k points
0 votes
1 answer 17 views
17 views
Briefly explain in java to how one should print the matrix with a simple example.
asked Dec 21, 2020 ZarinaShaik 320 points
0 votes
1 answer 8 views
8 views
I am new. Please solve this problem.
asked Dec 19, 2020 TeamScript 9.9k points
0 votes
1 answer 36 views
36 views
Problem: Guys help me. I am facing problem in printing or making logic of tower of honai in java. Please explain it with example.
asked Nov 6, 2020 Mubashi-Question 1.7k points