Nevermind, after almost 9 searches on google i found the answer..
fread won't append /0 to the end of the buffer it read, so i put it manually there, using the fread return value and it's working fine.
edit:
if any mod want to delete this one, you can do it. Thanks.
User Profile
Collapse
-
Error while reading text file using VisualStudio. (duplicate lines)
I'm writing a parser, and im totally confused. Its apparently correct, but something is happening:
I do a fread command to a char array of the entire file (it isn't big), this is the file:
Code:sphere { center <-3,0,0> radius 2 } light { direction <1, 1, 1> color rgb(1,1,1) } camera { parallel position <1,0,0>
-
write a loop, and keep an int, starting on "1". this will be the number of chars you will be printing, and an int that keeps the amount of chars you already printed.
so:
Code:while( bool value ) the for here (numbers of chars to print on current line) print one char increment amount of chars printed if you have printed all chars from the sentence loop
Leave a comment:
-
If you create a array of 10 elements, you will have 10 positions, but the first one is 0, so you will have an array from [0] to [9], thats 10 elements.
If you build a "Hello" string(lets say called st) it will be like this:
Code:st[0] = 'H'; st[1] = 'e'; st[2] = 'l'; st[3] = 'l'; st[4] = 'o'; st[5] = '\0';
Leave a comment:
-
Yep, in c there is no cin and cout, so use printf and scanf.
But theres something else:
* On pure C variables declarations are the first lines of each function.
* this statement:Code:for(int i=2 ; i<=x ; i++){
Leave a comment:
-
I can't see your question there... people won't do the entire code for you, you have to start it and when you have a question/error will help you.
You can start with the cctype (ctype.h) library, there are functions that will check/set your chars to lower/upper case. As for sockets, you have to google it or read a book.
For your third exercise you can use strtok (tokenizer) and capitalize the first letter.
For...Leave a comment:
-
That's a really probable issue.. but the thing is i just finished my code, and it some files work, others don't. They are exactly the same in the end of file, no blank line, just the last edge and nothing else, i just can't figure out why this happen.
edit: forgot to say something.. i left the idea of reading an DIMACS file and writing in a simpler format, i now just read the input from the DIMACS file, and it stills send me an error....Leave a comment:
-
Segmentation Fault using fprintf (really weird)
I wrote a translator, that reads a DIMACS graph format and writes to a simpler format...
basically DIMACS format is:
Code:c comment p type nodes edges //type is alwats edge on my problems, nodes is the number of nodes and edges number of edges e v1 v2 //this means an edge connecting v1 and v2, both integers
Code:c FILE: miles500.col
No activity results to display
Show More
Leave a comment: