I have to store UART incoming data in text file created in SD card interfaced with cc2652RB LP via SPI.
That means you not only need to have a driver in your firmware that knows how to talk "SD card protocol over the SPI controller in your microcontroller", but also that you need a file system driver (otherwise, the concept "file" doesn't exist). That file system driver needs to read the structure of data on the SD card, and know what a file is, how to create one, how to write the data into the right places...
So, look for SD Card drivers and file systems for your microcontroller. I'm sure the examples of your board come with something like that.
Can I use the following logic along with other declarations?
that means nothing, because it literally says "Can I use the following code, but after completely replacing it with something else".
fwrite(str, 1, strlen(str), src)
aside from the missing semicolon:
No. fwrite
is a POSIX operating system function. Your microcontroller isn't running a POSIX operating system.
You need to find a file system driver for your board / microcontroller and read the documentation of that.