Question d’entretien chez Carrier

What is structure padding Write a code for string reverse using pointer What is difference between ac and dc current?

Réponse à la question d'entretien

Utilisateur anonyme

16 janv. 2025

What is Structure Padding? Structure padding is the process of adding extra memory (padding bytes) between the members of a structure to align the data in memory for faster access. Compilers align structure members on boundaries (e.g., 2-byte, 4-byte, or 8-byte) based on the system's architecture or the compiler's requirements. Padding ensures that members are efficiently accessed but might increase memory #include #include void reverseString(char *str) { char *start = str; char *end = str + strlen(str) - 1; char temp; while (start < end) { temp = *start; *start = *end; *end = temp; start++; end--; } } int main() { char str[] = "Hello, World!"; printf("Original String: %s\n", str); reverseString(str); printf("Reversed String: %s\n", str); return 0; }