Remove first char of string C -
After the
im, compile my current code and on how to confuse the first character of im series and remove Fix it by trying to keep the balance.
My code:
char * newStr (char * charBuffer) {int len = strlen (charBuffer); Int i = 1; Four V; If (charBuffer [0] == 'A' || charBuffer [0] == 'Q') {for (i = 1; I & lt; lane; i ++) v = v + charBuffer [i]; } V = v + '\ 0'; Return vi; }
GCC: "WARNING: Return indicator creates an integer without integer"
Also: "four * newStr (four * charBuffer)" remain the same So that
String does not work like this in C. You can summarize all the characters in the buffer v
in the variable you can not use to add +. .
Try this:
Try this:
Try this: {Int length = strlen (charBuffer); Four * str; If (length & lt; = 1) {str = (four *) malloc (1); Str [0] = '\ 0'; } Other {str = (four *) maulok (length); Strcpy (str, and four buffers [1]); } Return str; }
or this:
Depending on whether you want to allocate a new string or not. You also need to add code to handle cases that do not begin with 'Q' or 'A'. I did not include them because I'm not sure what you are trying to do here.
Ensure that you do some research on allocation and deletion of memory with free meals and freebies. If you are going to do C programming, then this is a fundamental task to be able to use it.
Comments
Post a Comment