strncpy() Function Implementation | C Programming Example

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

You are amazing. Heartfelt thank you from a fellow Canadian. 🤗

EchoVoidHQ
Автор

doubt:
A program in the language c, that does the following:
of a file A and a file B.
From file A it will read each row and each value in the row will assign it to a variable, except the first one which will assign it to an array. The first row will contain from 1 to n values, separated by the tab and that will be an array which will be a counter to do the following:
The entire contents of file B will be read and assigned to a variable, for example: variable Bfile .
For each element of the matrix, a text will be replaced inside the Bfile variable, and a file will be created for each element of the matrix.
example:
file A:
dataone \t datatwo \t datathree
value2
value3
value4
value5
B-file
foo foo foo Datartoreplace1 foo foo foo Datarepalce2 foo foo foo Datarepalce3 foo foo Datarepalce4 foo foo Datareplace5
Process
step one .- Read all the contents of file B and assign it to a variable, called Bfile.
step two.- read file A, create an array with the data from row 1 with the name arrayElements (in the example it is an array of three elements).
step three.- Assign the value of the second row of file A to the variable ReplaceValue1.
step three.- Assign the value of the third row of file A to the variable ReplaceValue2.
step three.- Assign the value of the fourth row of file A to the variable ReplaceValue3.
step three.- Assign the value of the fifth row of file A to the variable ReplaceValue4.
step four.- for each element of the arrayElements array, replace the first element of the array inside the Bfile variable with the text Datartoreplace1; replace the text Datarepalce2 with the variable ReplaceValue1; replace the text Datarepalce3 with the variable ReplaceValue2; replace the text Datarepalce4 with the variable ReplaceValue3; replace the text Datarepalce5 with the variable ReplaceValue4;
and at the end of the loop, save a text file with the name of the array element, in this case dataone . Do the same for the other elements.

robertocruz
Автор

I have a situation where i have to copy the end of the string instead of the first few characters of the string, how can I do it?
Eg. you input into the terminal going './bin/library bin/books.txt' but i just need the 'bin/books.txt' bit to be used inside a fopen() function, and the .txt file could be another file name with longer characters, so how can I make it possible? Thank you!

yamithere_
Автор

Thanks for another wonderful video.
May suggest naming the string char array something other than string? It is may be confusing since you are using string library and there is also string is a class in C++.

qcnck
Автор

Thanks/ this kind of example is perfect

t
join shbcf.ru