Program that finds every other character in the first half of a char array in C -


this first part of program , have few questions on how parts of work exactly. keep in mind first c program have written. scanf("%d",&numberoftimes); why need & , do? char input[][200]; array of strings or different?

#include <stdio.h> #include <string.h> char outputs[100]; char input[][200]; int numberoftimes;  void io(void){     scanf("%d", &numberoftimes);     for(int = 0; < numberoftimes; i++){         scanf("%s",input[i]);     } } 

this next part of code attempt @ solving problem suspect screwed use of function don't know 1 or used improperly in order result. (i provided example i/o of me code @ bottom).

void stringmanipulation(char string[200]){     int strlength = strlen(string);     int number = strlength/2;     for(int = 0; <= number; i=i+2){         strcat(outputs,&string[i]);     } }    int main(void) {     io();     for(int = 0; < numberoftimes; i++) {         stringmanipulation(input[i]);         printf("%s\n",outputs);         memset(&outputs[0], 0, sizeof(outputs));     }     return 0; } 

did use memset properly? again don't understand use of &.

example input:

4   progress   noticeable 

expected output:

y  po   ntc 

output getting:

yourur  progressogressress   noticeableticeableceable 

thank help.

the & before variable means referring address of variable, , not variable value itself. if don't know address of variable : http://www.cquestions.com/2010/02/address-of-variable-in-c.html

char input[][200] array of char array (a char array vulgarized string isn't type).

your problem strcat use, you're adding characters between string[i] (included) , string[strlength], not string[i] character.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -