70 Posted Topics
Re: #include <stdlib.h> #include <stdio.h> int main() { int iToHex = 2346; printf("%x",iToHex); return 0; } outputs 92a or if you wish you can sprintf it somewhere or use unsigned char for value < 255 #include <stdlib.h> #include <stdio.h> #include <string.h> int main() { int iToHex = 255; unsigned char pcBuffer[sizeof(iToHex)] … | |
Re: what do you know ? if you know that it is delimited with space before then read it from end of file till space or read some size and parse and then atoi look Maximum value for a variable of type int. 2147483647 for example i could fseek to end … | |
Re: something like that could be design m? #include "stdio.h" #include "stdlib.h" #define APLPABET_LEN 2//should be 25 struct stAlpha { int iCount; char cChar; }; enum { CHAR_A = 0, CHAR_B = 1,//add needed indexes }; void vPrintResultAlpha(stAlpha stAlphabet[]) { int i = 0; for (i; i < APLPABET_LEN; i++) { … | |
Re: comment out lines with errors, then slowly uncomment and look for errors next time you write something, compile it every time you add something new while you are learning | |
Re: [this is the link on howto do it](http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/) 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 … | |
Re: try this ? just check everywhere for NULL where possible :) row = mysql_fetch_row(result) while (row != NULL) { for(i = 0; i < num_fields; i++) { //printf("%s ", row != NULL ? row[i] : "NULL"); printf("%s", row[i]); } printf("\n"); row = mysql_fetch_row(result) } | |
Re: same as for static, you use array index to access elements [Click Here For Malloc this is dynamic array](http://www.cplusplus.com/reference/clibrary/cstdlib/malloc/) | |
Re: #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 … | |
Re: 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 | |
![]() | Re: 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 |
Re: this one ? [cplusplus.com/reference/clibrary/cstdarg/va_arg/](http://www.cplusplus.com/reference/clibrary/cstdarg/va_arg/) | |
Re: 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'; | |
Re: http://www.daniweb.com/software-development/c/threads/198632/how-to-compile-and-link-two-c-files- | |
Re: 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, … | |
Re: use struct, write your own vector | |
Re: 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]); } | |
Re: 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 | |
Re: 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 … |
The End.