LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-15-2007, 05:24 PM   #1
xeon123
Member
 
Registered: Sep 2006
Posts: 374

Rep: Reputation: 16
String manipulation in C


Hi,

I'm sorry, but I kind of a newbie in C.

In C, how do I check that a string starts with a specified string?

For example:
startsWith("ls", "ls -la");

Thanks,
Pedro
 
Old 10-15-2007, 06:00 PM   #2
xeon123
Member
 
Registered: Sep 2006
Posts: 374

Original Poster
Rep: Reputation: 16
I just found the solution.

I only had to use strncmp.
 
Old 10-17-2007, 02:17 PM   #3
student04
Member
 
Registered: Jan 2004
Location: USA
Distribution: macOS, OpenBSD
Posts: 669

Rep: Reputation: 34
Lightbulb

Quote:
Originally Posted by pedrosacosta View Post
Hi,

I'm sorry, but I kind of a newbie in C.

In C, how do I check that a string starts with a specified string?

For example:
startsWith("ls", "ls -la");

Thanks,
Pedro
Two sites that are of great help:

http://www.cppreference.com

http://www.cplusplus.com (Just use the search bar above and look through what it finds as relevant.)

Enjoy.

-AM
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash string manipulation kpachopoulos Programming 3 06-17-2007 07:45 PM
string manipulation in BASH ovince Programming 4 04-16-2007 08:15 PM
String manipulation Manuel Alvarado Linux - Newbie 2 09-06-2006 10:49 PM
string manipulation mannahazarika Programming 6 12-31-2005 12:02 PM
String manipulation with a script. philipina Programming 4 03-16-2004 03:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration