11 years, 3 months ago.

.gets function

Hi,

I've been trying to use the .gets function but I am having problems. What I'm trying to do is make LED1 light up if someone types "One" into the terminal. Below is the code I was using to do this. I have tried a similar thing with getc and it worked fine. Any idea what I'm doing wrong or where to find more information on the gets function.

Cheers, Matt

void PowerMonitor::serialSend() { DigitalOut myled(LED1);

if ( pc.readable()==1) {

char s[128];

if(pc.gets(s,3) =='One') { myled = 1; } } }

Question relating to:

1 Answer

11 years, 3 months ago.

Never mind I was being a bit think

My if statement should have been

if(pc.gets(s,3) =="One") { myled = 1; } } }

With " around one not '

Accepted Answer