you need to read about it, what it is and then construct it

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define HOW_MANY_CHARS 2
int main()
{
   char *s = NULL;//does not point to allocated memmory

   s = (char*) malloc (sizeof(char) * HOW_MANY_CHARS);//create nice old string
   memset(s, 0, HOW_MANY_CHARS);//initialize it to zeroes

   gets(s);//though better to use getchar and check for overflow

   printf("[%s]\n",s);// print whole c string
   printf("[%c]\n",s[0]);//acces first char and print it

   free(s);

   return 0;
}

this is the link on howto do it

try to compile hello world program first maybe error is in your code ? cause char* ItemType; is pointer to memmory did you allocate some memmory for it ?

and you read to char lineRead; which is actually one byte long, you read there 120 bytes
it should be then char lineRead[120]

'Segmentation fault(core dumped)'. means memmory error

please exlayn how you calculated 4rd line ? from n/21 till n/5 why not other i mean if n is 21 then 21/21 is from 1 till 4.2 like O(n/5) dont know
i am interested in a result too

if(answerInput[count][i]=='.')
{
    printf("ERROR");
    break;
} 

or something like that is possible bot i didnt tested just a sketch

//read 
char c = getchar();
while(c!='.' && i<SIZE)
{
    answerInput[count][i++] = c;
c = getchar();// get next char then
}
answerInput[count][--i]='\0';

How does this create a huge security hole and reallocating the array by 1 for each input doesn't? Keep in mind the info we have been given by the OP, not making unfounded assumptions about what we haven't been told..

maybe if you check for array overflow and realloc error then no holes

WaltP commented: Yes, if you program properly, there will be no holes. +14

wouldnt the first one be O(n) or more precise O(n + 66) ?
second dont know it's just math something line n * 16 can exyst

dont haveto deal with zeroes in the front, you must sort only length with needed data, no need to sort whole array
just hold variable iLen look at bubble sort
if it crashes then malloc array dynamically at the start

have you considered java ?

WaltP commented: How does that help in passing from C to PHP??? +0

post your code we will comment

+1 for undefined, cause printf in your project library maybe written differently or that can be compiler specific no ?
anyway why would someone write like that and care about it?? :))

malloc new bigger size, copy all data there :) free old memmory and make old pointer to point to new memmory i think this is the concept

After 7 years one would hope said junior computer student has been in the industry for a few years and can finally understand pointers... ;o)
Maybe it would be better if people stop resurrecting long dead threads with worthless posts.

sorry i needed fast solution and found this thread on google, maybe this answer will help to someone

you might use my stack for examle it should work

#include <stdio.h>
#include <stdlib.h>

#define ER_EMPTY_STACK -1

#define MSG_EMPTY_STACK "Stack is Empty\n"
#define LOG_ENABLED
struct stElem
{
   int iData;
   stElem *stNext;
};

stElem *stStartPtr = NULL;

int iPrintList()
{
   stElem *stCurrent;
   stCurrent = stStartPtr;
   int iElementCount = 1;
   while(stCurrent != NULL)
   {
      printf("#%d [%d] ",iElementCount ,stCurrent->iData);
      stCurrent = stCurrent->stNext;
      iElementCount++;   
   }
   if(iElementCount != 1 )
   {
      printf("\n");
   }
   printf("Total of elements [%d]\n",iElementCount - 1);   
   return iElementCount - 1; 
}

int iPop()
{
   int iSavedData = ER_EMPTY_STACK;
   stElem *stTmp = NULL;
   if(stStartPtr != NULL)
   {
      iSavedData = stStartPtr->iData;
      #ifdef LOG_ENABLED
      printf("Pop [%d]\n", iSavedData);
      #endif
      stTmp = stStartPtr;
      stStartPtr = stStartPtr->stNext;
      free(stTmp);
   }
   else
   {
      iSavedData = ER_EMPTY_STACK;
      printf(MSG_EMPTY_STACK);
   }
   return iSavedData;
}
int iPush(int iData)
{
   stElem *stTmp = NULL;

   if(stStartPtr == NULL)
   {
      stStartPtr = (stElem*)malloc(sizeof(stElem));
      stStartPtr->stNext = NULL;
      stStartPtr->iData = iData;
      #ifdef LOG_ENABLED
      printf("Push to empty stack [%d]\n", stStartPtr->iData );
      #endif
   }
   else
   {
      stTmp = (stElem*)malloc(sizeof(stElem));
      stTmp->iData = iData;
      stTmp->stNext = stStartPtr;
      stStartPtr = stTmp;
      #ifdef LOG_ENABLED
      printf("Push [%d]\n", stTmp->iData);
      #endif
   }

   return 0;
}

void vLinkedListProgram()
{
   int iCounter = 50000;
   printf("Press to allocate");
   getchar();
   while(iCounter-- > 0 && iPush(iCounter) == 0); 
   printf("Press to free");
   getchar();
   while(iPop() != ER_EMPTY_STACK);

   /*iPop();
   iPop();
   iPop();
   iPush(888);
   iPush(999);
   iPrintList();
   iPop();
   iPop();
   iPrintList();*/
}

int main()
{

   while(1)
   {
      vLinkedListProgram();
   }
    return 0;
}

Thanks for your reply.
Actually i don't know what should i do with push_back! is there any replace things for push_back?!
Thanks

yes, it means you haveto write your own vector,list
or write it to an end of array

use struct, write your own vector

dont use printf(buffer); to debug

memset(buffer,0,sizeof(buffer);
//fill it with data
for (i=0;i<sizeof(buffer);i++)//print every element
{
    printf("[%c]",buffer[i]);//or printf("[%d]",buffer[i]);
}

use array index and no need to return nothing, just print name afterwards :)
by the way you are not modifying char* and returning from a function, you are modifying the data that pointer points to and returning pointer to that data

I've mentioned the line numbers where i'm facing probs..!!!

    if(head != NULL)//check does head point somewhere on initialised memmory cause after free it should point to NULL
    {
        if(strcmp(del_c,head->c) != 0)//does it have data that we need
        {
           //handle
        }
    }

please comment your code next time, or explain it to your cat hope this helps :)

void del()
{
   XY:
   char del_c[30];
   printf("Enter the name of city to be deleted: ");
   scanf("%s",del_c);
   struct city *tmp,*prev;
   tmp = head;
   if(strcmp(del_c, head->c) == 0)//if data that head points to matches or just segfault if null pointer
   {
      head = head->next;//make head point to next element
      free(head);//delete next element
   }
   else
   {
      while(strcmp(del_c,tmp->c) != 0)//while does not match // better to look for NULL pointer before accessing
      {
         prev = tmp;
         tmp = tmp->next;//search from head till the system error or we find something before
      }
      prev->next = tmp->next;//we found something or not, lets make something point somewhere after next in linked list
      free(tmp);//free something maybe would be ok if we find something
   }
   if(strcmp(del_c,head->c) != 0 || strcmp(del_c,tmp->c) != 0)//head might not exist - seg fault or tmp
   {
      printf("City is not there in list");
      goto XY;//using goto is bad practise
   }
}

i think this should work any idea how to do better ?

void vRemoveDelimiters(char *pcBuffer, char* pcDelimiters)
{
   int i = 0;
   int iLen = strlen(pcBuffer);

   for(i = 0 ; i < iLen; i++)
   {
      if( strchr(pcDelimiters, pcBuffer[i]) != NULL )
      {
         memcpy(&pcBuffer[i], &pcBuffer[i + 1], iLen - i);
         iLen--;
         i--;
      }

   }
   return;
}

maybe this ? please review

void vRemoveDelimiters(char *pcBuffer, char* pcDelimiters)
{
   int j = 0;
   int i = 0;
   int iLen = strlen(pcBuffer);

   for(i = 0 ; i < iLen; i++)
   {
      if( strchr(pcDelimiters, pcBuffer[i]) != NULL )
      {
         j = i;
         if(strchr(pcDelimiters, pcBuffer[j + 1]) != NULL)//next is delimiter, start from this position agayn after
         {
            i--;
         }
         memcpy(&pcBuffer[j], &pcBuffer[j + 1], iLen - i);
         iLen--;
      }

   }

   return;
}