User Profile

Collapse

Profile Sidebar

Collapse
spiralfire
spiralfire
Last Activity: Dec 8 '09, 10:48 PM
Joined: Nov 10 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • 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.
    See more | Go to post

    Leave a comment:


  • 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>
    ...
    See more | Go to post

  • 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
    ...
    See more | Go to post

    Leave a comment:


  • spiralfire
    replied to strings
    in C
    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';
    This array could have a minimum of 6 elements.....
    See more | Go to post

    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++){
    isn't allowed in C, you can't declare a variable in the for statement, in the beginning of the function as stated before....
    See more | Go to post

    Leave a comment:


  • spiralfire
    replied to Server-Client with this with these functions
    in C
    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...
    See more | Go to post

    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....
    See more | Go to post

    Leave a comment:


  • spiralfire
    started a topic Segmentation Fault using fprintf (really weird)
    in C

    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
    this is the file im using:

    Code:
    c FILE: miles500.col
    ...
    See more | Go to post
No activity results to display
Show More
Working...