Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Reading a string with white space in C

Status
Not open for further replies.
I know this is kind of late, but I feel obligated to share this info. To get "white space" with the rest of your string until enter is pressed you could use the following code I got from here https://www.cplusplus.com/reference/string/getline/

Example:
Code:
#include <iostream>
#include <string>

int main()
{
string path;

cout << "Enter some text with white space: ";
getline(cin,path);
cout << "You entered: " << path << endl;
}
 

That's C++ instead of plain old 'C' but as the original poster didn't specify a version of the language maybe it is applicable in this case.

Brian.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top