Parsing an array of chars

Let's say I have "game.abc" as a string (array of chars) and I want to get the chars that are before the dot. What you would deem to be the most efficient way to do this in C?

Is a "while until . copy char to char" the way to go or is there any other way?

I hope this question can help others also.

Thanks!

Answers


you can also use strchr() followed by strncpy() to find first instance of '.' in your string and then copy all characters before it to another string


Need Your Help


About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.