- Strength to Increase Rep
- +5
- Strength to Decrease Rep
- -1
- Upvotes Received
- 9
- Posts with Upvotes
- 7
- Upvoting Members
- 7
- Downvotes Received
- 4
- Posts with Downvotes
- 4
- Downvoting Members
- 2
- Interests
- different kind of stuff
- PC Specs
- dell vostro v131, celeron 867, archlinux openbox
70 Posted Topics
Re: you need to modify only pointer "next", do you know what linked list is? If you know then you can draw something that you whant to do with it and then program this behaviour | |
Re: When you subtract two pointers, as long as they point into the same array, the result is the number of elements separating them and in this case each int is 4 byte for example.. then you get this otput on my pc: size of int 4 ptr before changes 2293496 … | |
Re: Try otputing to another file instead of windows console and read, as i see you use dos include. Please note that windows new line is not '\n' because it's one byte in linux LF and 2 byte in windows CR+LF please see http://en.wikipedia.org/wiki/Newline | |
Re: paste this into your file manager to test c:\\TurboC++\\Disk\\TurboC3\\sample.txt or use sameple.txt and put it in same dir as your exe | |
Re: are you shure you can use [fgets](http://www.cplusplus.com/reference/clibrary/cstdio/fgets/) ? why dont you use fread for start and try to copy image ? You can also use some hex editor to compare values. **fgets is for text...** | |
Re: if(dist<dr); remove semicolon ? should be or it will do nothing if dist < dr and do nothing on else if(dist<dr) { printf("checkcollision read true\n"); printf("dist: %f, radius+radius: %f\n",dist,dr); goback(0); goback(1); } | |
Re: It looks like it works, please explain better or post file. Also, yes you should take hex editor to know exactly wat you are dealing with.. If it is not 8bit chars then you need to parse it differently.. check out dragon post http://www.daniweb.com/software-development/c/threads/254246/how-to-read-unicode-utf-8-binary-file-line-by-line | |
Re: you reference wrong address, this causes core dump yes ? you add fprintf and maybe initialise some memmory then reference it by mistake, this could be answer m ? check address you reference, and addresses you allocate with memmory | |
Re: this for date ? :) and it should be very portable [Click Here](http://www.cplusplus.com/reference/clibrary/ctime/) | |
Re: you are not the first nor the last who needs to read from file, search google, good luck to you :) http://www.cplusplus.com/reference/clibrary/cstdio/fopen/ | |
Re: can you try this ? or strtol, please say if works while(fscanf(f,"%d",&value) == 1) { /* do something with the value */ } | |
Re: maybe you can use this http://www.cplusplus.com/reference/clibrary/cstdlib/strtol/ #include <stdlib.h> int main() { char *pEnd; printf("%ld\n",strtol("A",&pEnd,16)); return 0; } | |
Re: #include <stdio.h> #include <stdlib.h> #include <string.h> #define HOW_MANY_STRUCTS 20 #define MAX_NAME_LENGTH 30 typedef struct ritnish { int iRoll; char pcName[MAX_NAME_LENGTH]; }stRitnish; int main() { stRitnish s[HOW_MANY_STRUCTS] = {0}; srand(time(NULL)); memcpy(s[0].pcName, "TestName!",sizeof("TestName!")); s[0].iRoll = rand() % 1000; printf("Printing name [%s] and number %d\n", s[0].pcName, s[0].iRoll); return 0; } > ok waltp … | |
Re: post some example of log file, and what do you expect of it | |
Re: this i wrote for linux what is your platform ? my ubuntu - gcc #include <time.h> #include <stdio.h> int main() { time_t startSeconds; startSeconds = time(NULL); while(1) { system("clear");//platform specific check your platform this is linux/unix printf("%ld \n", time(NULL) - startSeconds); sleep(1);//platform specific check your platform and change this is … | |
Re: float is 8 bytes and int 4 bytes if you say %f you expect 8 bytes and type float #include <stdio.h> int main() { int iInt = 1; printf("int %d float %f",iInt, (float)iInt); return 0; } btw i suggest you read char buffer in and then convert it to float … | |
Re: use this http://www.daniweb.com/software-development/c/threads/429412/string-in-matrices | |
Re: this is what it means fifth is null terminator 065 in oct is '5' check ascii table #include <stdio.h> int main() { char str[]="S\065AB"; char strSame[5] = { 'S','\065', 'A', 'B', '\0'}; printf("str 1 %d \n", sizeof(str)); printf("str 2 %d\n", sizeof(strSame)); printf("same ? %d [%s] [%s]",strcmp(str, strSame),str, strSame); return 0; … | |
Re: [Arguments to main click](http://publications.gbdirect.co.uk/c_book/chapter10/arguments_to_main.html) | |
Re: or something like that #include <stdio.h> #include <stdlib.h> #include <string.h> char *safe_gets(char *buf, size_t size) { if (!fgets(buf, size, stdin)) return NULL; buf[strcspn(buf, "\n")] = '\0'; return buf; } int main(void) { char str[7] = {0}; int i, k = 0; int iLen = 0; printf("Enter string 1: "); fflush(stdout); … | |
![]() | Re: take a look at this [Click Here](http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operator_precedence) ![]() |
Re: int a[]={1,2,3,4,5,6,7,8,9,10}; You allocate memmory on stack here and a points to that memmory. Then pointer b points to that memmory location b=a i mean now b and a point to same location so you can work with it same as with a here you can try to print it's … | |
![]() | Re: here is good link i found on google [Click Here](http://www.daniweb.com/software-development/c/threads/50370/starting-c-) ![]() |
Re: Actually all you need is to call function bigger 3 times in printbiggest. If input parameters x i z j bot you will need extra parameter inside function iMax first you get to know x and y biggest then save it and compare it to z then save it and … | |
Re: use printf("size of char %d size of int %d",sizeof(char),sizeof(int)); bot pointer is always 4 byte no ? maybe you can try to cast to char ? by the way where is problem? strcpy(*rowptr,"d"); strcpy(*(rowptr+1),"c++"); printf("ROWPTR+1[%s]",*(rowptr + 1)); strcpy(*(rowptr+2),"java"); printf("ROWPTR+2[%s]",*(rowptr + 2)); they print correct, no ? please see howto allocate … | |
Re: do you know how to create linked list ? if yes then to reverse you can use this post [Click Here](http://www.daniweb.com/software-development/c/threads/426342/singly-link-list-backward) you just take your list and while you traverse it just move to new in reversed order | |
Re: > Is it necessary to free the memory of the node that is deleted? What do you mean deleted then ? In c if you loose pointer to some data it is called memmory leak, cause no automatic garbage collection is implemented in c. In java if all references lost … | |
Re: use this [Click Here](http://stackoverflow.com/questions/1534912/how-to-build-in-release-mode-with-optimizations-in-gcc) ifeq ($(BUILD),debug) # "Debug" build - no optimization, and debugging symbols CFLAGS += -O0 -g else # "Release" build - optimization, and no debug symbols CFLAGS += -O2 -s -DNDEBUG endif all: foo debug: make "BUILD=debug" foo: foo.o # The rest of the makefile comes here... | |
Re: should it work same as strtok ? try not to use malloc and use array index instead of pointer arithmetic then when it works you can try pointer arithmetic(just increment address instead of index) and malloc Make working code and convert would be more easy maybe :) | |
Re: Maybe it is [stack](http://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29#Linked_list) ? you push new to first and then pop from first till last ? :) that will be reverse | |
Re: [Operator precendece](http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operator_precedence) maybe this will help [Click Here too](http://stackoverflow.com/questions/4017954/expression-evaluation-in-c-c-doesnt-follow-bodmas-rule) | |
Re: i like visual studio at work cause it's easy to navigate big project, bot at home i usually use vim, gedit maybe kate. I use notepad++ too sometimes at work, it's great. | |
Re: Would be interesting to see example of what you are doing :) I dont understand how to do it, just use bitwise logic operators and if else ? I remember from school we had special graphical program where you can move and connect all that stuff to simulate this. | |
Re: There are many ways to do this. What about the idea to use linked list and insert new names in correct place every time it is entered? Or even better would be binary tree. Or use some array of pointers to swap pointer values instead of struct values you can … | |
Re: alternative is [malloc](http://www.cplusplus.com/reference/clibrary/cstdlib/malloc/) you will locate it on heap instead of stack or calloc effect is same bot you haveto free it after and it can be dinamically changed during execution :) | |
Re: See, if it confuses you so much then maybe separate calculation and printing, and print result variable only. Also can write function to calculate | |
Re: Most simple solution if you know max line length and max text length would be using [fgetline](http://www.cplusplus.com/reference/clibrary/cstdio/fgets/) then compare what you got to desired if it is it read next line data. with the same thing [fgetline](http://www.cplusplus.com/reference/clibrary/cstdio/fgets/) or [fread](http://www.cplusplus.com/reference/clibrary/cstdio/fread/) bot then you haveto parse chunks which would be more harder … | |
Re: yes qsort is good example as deceptikon told. Bot it is not possible to pass only array or struct, you need to tell to a function howto compare those values. For example in qsort for struct it could be a.data > b.data | |
Re: enum or define of possible values and switch no ? #include <stdio.h> enum eGprsEnum { GPRS_T = 3, GPRS_X = 1000, }; int iDoStuff(int iId) { int iRet = 0; switch(iId) { case GPRS_T: printf("%d",iId); break; case GPRS_X: break; default: iRet = -1; break; } return iRet; } int main() … | |
Re: @hanananah also will work for original poster you guys better use this one [strtok](http://www.cplusplus.com/reference/clibrary/cstring/strtok/) or if you know pointers good, you can locate it '|' with [strchr](http://www.cplusplus.com/reference/clibrary/cstring/strchr/) if you have only one of these, if you have more you can ofcourse make it work too. Or do it manually, going … | |
Re: use getchar instead of fgets [Click Here](http://www.cplusplus.com/reference/clibrary/cstdio/getchar/) your face is 2 bytes, you read 3 in it | |
Re: The moust simple way is that you can have max like 300 accounts(300 structs) and 100 users(structs) 2 banks structs then you link them somehow together this does not need to be effective way, cause data is very small. See for example to be easy you can store 3 account … | |
Re: Another possible solution #include <stdio.h> #include <stdlib.h> #include <string.h> void vPassByValue(const void * const vData, int iSizeOfData) { void *vCopyData = NULL; vCopyData = malloc(iSizeOfData); if(vCopyData != NULL) { memcpy(vCopyData, vData, iSizeOfData); printf("passed by value %s\n",vCopyData); memset(vCopyData, 0, iSizeOfData); } free(vCopyData); return; } int main() { char pcBuffer[20] = {0}; … | |
Re: if it is binary value stored then you can read first 8 bytes in float variable and second 8 bytes in float variable i just dont see where you open different files or i dont understand | |
Re: dont use sizeof. do track memmory manually or use static buffers for now, and if everything works, try to change them | |
Re: you need to read about it, what it is and then construct it | |
Re: look at [Ascii table](http://www.asciitable.com/) all i whant to say that char is not int, it is one byte - 8 bites combination #include <stdio.h> int main() { /*unsigned*/ char ucChar = 171; int iBit = 7; while(iBit >= 0) { printf("%d", (ucChar &(1 << iBit)) ? 1 : 0 ); … | |
Re: dont know, maybe you can play with this code i wrote using printf and figure it out, it will be fun #include <stdlib.h> #include <stdio.h> #include <string.h> int main() { int * piInteger = NULL; int iInteger = 0; void *vPointer = NULL; char *pcBuffer = {"xyz"};//3 bytes and null … | |
![]() | Re: [Why you shouldn't use Dev-C++](http://www.jasonbadams.net/20081218/why-you-shouldnt-use-dev-c/) ![]() |
Re: i recommend you use [fgetc](http://www.cplusplus.com/reference/clibrary/cstdio/fgetc/) if you do not know max len of line and dont want to concatenate using fread also look at [atoi](http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/) |
The End.