Home > Blockchain >  Writing into a malloc string
Writing into a malloc string

Time:09-13

I'm new to C programming language, and malloc precisely. So I created this program to take arguments from argv and put them all in a single string, separated by spaces(on line 32). But when I run it, everything works out, but there seems to be no spaces inserted as desired in the code below.

When I tried commenting, line 28: buffer[t] = argv[str][i]; the spaces appear.

I also tried casting: malloc(buffSize) to (char*) before assigning it to buffer to just see if anything changes¿¿. But nothing.

Please I'd be glad if someone can clear me out on what's going on. Thanks in advance

  • Related