# Difference Between Begin and Cbegin

By: | Updated: Aug-13, 2022
The contents of the Difference.guru website, such as text, graphics, images, and other material contained on this site (“Content”) are for informational purposes only. The Content is not intended to be a substitute for professional medical or legal advice. Always seek the advice of your doctor with any questions you may have regarding your medical condition. Never disregard professional advice or delay in seeking it because of something you have read on this website!

In vector programming, you will often need to convert between different types of vectors. For example, if you have a vector of doubles and a vector of floats, you may want to combine them into a single vector of doubles. The C standard library has two functions for this purpose.

## Summary Table

 Begin Cbegin Begin is a reference to the beginning of the vector. Cbegin is a reference to the beginning of the array. Begin is a statement that can be used to begin a loop. Cbegin is a statement that can be used to begin a control flow construct. Begin is a function call that returns a vector. Cbegin is a function call that returns an array.

Begin creates a vector of a given type. If the given type is not supported, the value returned is a vector of the same type as the input. For example, if you have an array of doubles and you want to create a new array of doubles, you would use begin(double). The result will be an array of doubles with twice as many elements as the input.

Cbegin(type) creates a vector with the same size as the input. If the input has fewer elements than the output, only those elements are copied into the output.

## What is Begin?

Begin takes a vector of doubles and converts it to a vector of floats. Begin is a function that takes a vector of doubles and converts it to a vector of floats.

## What is Cbegin?

Cbegin takes a vector of floats and converts it to a vector of doubles. Cbegin is a function that takes a vector of floats and converts it to a vector of doubles.

## The Similarities Between Begin and Cbegin

The similarities between begin and cbegin are as follows:

### Both take two arguments

Both begin and cbegin take two arguments: the first argument is the start index, and the second argument is the length of the array. This means that you can use begin to convert between vectors of different lengths.

### Both return a pointer to the first element of the array

Both begin and cbegin return a pointer to the first element of the array, so you can use this value as an index into the array.

### Both return an error if the index argument is negative

Both begin and cbegin return an error if the index argument is negative, so you can check for this before trying to access the array.

### Both are macros

Both begin and cbegin are macros. The difference is that begin returns a vector of integers, while cbegin returns a vector of characters.

## Begin VS Cbegin

The differences between begin and cbegin are:

### The statement

Begin is a statement that can be used to begin a loop. Cbegin is a statement that can be used to begin a control flow construct.

### The element

Begin is a reference to the beginning of the vector. Cbegin is a reference to the beginning of the array.

### The function call

Begin is a function call that returns a vector. Cbegin is a function call that returns an array.

(Visited 166 times, 1 visits today)
Did this article help you?
Thank you!
Thank you!
What was wrong?