How to Validate a Name in C/C++

Cloudmersive
1 min readJun 4, 2021

--

Is your system equipped to check online submissions for valid information, such as name values? If not, you may be opening your website or application up to potential ordering and contact errors. In this quick tutorial, we will demonstrate an API that can be used in C/C++ to automatically parse and validate a full name string, with no extra effort needed by you.

To begin, we will install libcurl into our C/C++ project:

libcurl/7.75.0

Next, we can call the validation function with the following code:

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.cloudmersive.com/validate/name/full-name");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{\n \"FullNameString\": \"<string>\"\n}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);

And that’s it! The only inputs you will need for this process are the target name string and an API key. If you need to obtain an API key, head over to the Cloudmersive website to register for a free account; this will provide access to 800 monthly calls across any of our APIs.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet