Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
your string is never nul-terminated because the line-ending logic has precedence over the nul-terminating logic in your
if/else
This comment is hidden because it contains spoiler information about the solution
it is now explained in the initial code
OP solved it, closing
start_address_of_string+strlen(string)-1 will give you the address of the last character.From there all you need do is dereference that pointer and compare with the ending part
Don't forget spoiler flag. Your code is basically:
This code means that it will only check 1 character and return instantly. At least one of these returns should be outside loops.
thanks
Looks like the size of the returned array.
You'll get a compiler warning when comparing the "int i" to "size_t arr_size".
Default int is signed, while size_t is unsigned. In practice it won't matter until the arrays get very large (not tried in this kata)
Unsigned Integer means that they have only positive values starting from 0.They donot have any negative values in their range.
In signed integers they have range of [-2147483648 to 2147483647] where as unsigned integer has range of [0 to 4294967295].
this is a data type which can store natural numbers from 0 to 2n - 1 where n is the number of bits (usually 32)
It depends what you want to represent with values of given type.
size_t
is meant to be used for sizes of objects and indices into arrays.float
is not suitable for that, because, for example, you cannot have an object of size3.5
. Its range can also be too small.int
can have smaller range thansize_t
on some platforms, so it's not guaranteed to work well for sizes and indices, especially for very large objects and arrays.size_t
is a type suitable for storing sizes of objects and often used for indexing.stddef.h
is required as one of header files which suppliessize_t
.size_t
is defined also in other header files (https://en.cppreference.com/w/c/types/size_t), so including any of them would be ok.stdbool.h
is required as a header file which providesbool
.stdio.h
, because, in its initial form, it does not use anything declared in this file. If your solution uses anything declared instdio.h
, you can include it.You created a new array instead of swapping the values of the original array. In this case,
args[0]
andargs[1]
still have the same values.Try to come up with one. You can also forfeit and unlock solutions, if you can't solve it.