User Profile

Collapse

Profile Sidebar

Collapse
Acolyte
Acolyte
Last Activity: Nov 15 '07, 06:54 PM
Joined: Jan 29 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Yeah, I noticed that right after I posted. However, I've changed that now, to no avail.
    See more | Go to post

    Leave a comment:


  • Acolyte
    started a topic More problems with string manipulation and seg faults
    in C

    More problems with string manipulation and seg faults

    Alright, here's what I'm working on now. It's supposed to go through an inputted list of words, pick out actual words and create a numbered list of them, then, where it finds a number in the list, go back in the list from that number, replace it with a word, augment the list accordingly and continue.

    Anyways, here's what I have:
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <ctype.h>
    ...
    See more | Go to post

  • Acolyte
    replied to Help with tokenizing
    in C
    NVM, I solved the initial problem, but I have a new one, which will be posted in a second.

    Anyways, strtok(NULL, " ") takes a string and seperates it based on where the spaces are. So, if the input was char test = {"These are a bunch of words."}, it would seperate it into "These", "are", "a", "bunch", "of", "words."

    Anyways, new problem:...
    See more | Go to post

    Leave a comment:


  • Acolyte
    started a topic Help with tokenizing
    in C

    Help with tokenizing

    Ok, the program I'm working on now involves taking an input string and tokenizing it, by seperating it by spaces. Here's what I've got:
    Code:
    #include <stdio.h>
    #include <string.h>
    
    int main (void)
    {
            char *tokenarray[100];
            char input[200] = {"Test , Test2"};
            char *tokenPtr;
            int cnt = 0;
    
            tokenPtr = strtok(input, "
    ...
    See more | Go to post

  • Acolyte
    started a topic Problems with file reading and strings
    in C

    Problems with file reading and strings

    Alright, as a continuation of my previous question, I've got two problems with this program-the file read only reads the last line of the input file, and, when I try to assign a tokened word to a spot in the array, it returns a segmentation fault. Anybody know what I'm missing?

    Code:
    #include <stdio.h>
    #include <string.h>
    
    int main (void)
    {
            FILE *file;
            file = fopen("input2.txt",
    ...
    See more | Go to post

  • Acolyte
    started a topic Help with reading in a string from a file
    in C

    Help with reading in a string from a file

    I'm working on a program that, eventually, is supposed to uncompress a text file where words are replaced by numbers. However, before I get to that part, I need a hand with reading in the text from a file and parsing it with strtok. Here's what I've got so far:
    Code:
    #include <stdio.h>
    #include <string.h>
    
    int main (void)
    {
            FILE *file;
            file = fopen("input2.txt", "r");
    ...
    See more | Go to post

  • Acolyte
    replied to Arrays and Pointers
    in C
    Ah, thanks DeMan, that was half the problem, and I realized the other half.
    The correct version is:
    Code:
    int BubbleSort (int numlist[], int size, int order)
    {
            int pass, num1, num2;
            int cnt;
                    for (pass = 0; pass < size - 1; pass ++)
                    {
                            for (cnt = 0; cnt < size - 1; cnt ++)
                            {
    ...
    See more | Go to post

    Leave a comment:


  • Acolyte
    replied to Arrays and Pointers
    in C
    Normally, I would and all would be well, except that the prof has specificed that we can't use Array[] anywhere other then the declaration of the array.
    See more | Go to post

    Leave a comment:


  • Acolyte
    replied to Arrays and Pointers
    in C
    sicarie-an incorrect value, namely the unsorted array. And the return 0; was a brain fart (It was originally in main before I reorganized the program-I just forgot to delete it!) However, removing it doesn't do anything.

    RedSon:
    Here's the call in main that calls the sort:
    Code:
    case 3:
                                    printf("Please enter the size of the array: ");
                                    scanf("%d",
    ...
    See more | Go to post

    Leave a comment:


  • Acolyte
    replied to Arrays and Pointers
    in C
    Yeah, sorry I wasn't more clear about it. The problem is that...well, it doesn't work. I think the problem is with the if ((numlist + cnt) > (numlist + cnt + 1)) and if ((numlist + cnt) < (numlist + cnt + 1)) statements-I think they don't cycle through the array properly.
    See more | Go to post

    Leave a comment:


  • Acolyte
    started a topic Arrays and Pointers
    in C

    Arrays and Pointers

    I'm currently working on some more stuff for an assignment, this time with pointers. The current task is to bubble sort an array using a extrnal swap function that uses pointers, and to reference the array without using the Arrayname[] operator.

    Anyways, here's what I've got:
    Code:
    int BubbleSort (int numlist[], int size, int order)
    {
            int pass, num1, num2;
            int cnt;
                    for (pass
    ...
    See more | Go to post

  • Acolyte
    replied to 2-dimensional array bubble sort
    in C
    That would be correct.
    See more | Go to post

    Leave a comment:


  • Acolyte
    replied to 2-dimensional array bubble sort
    in C
    Yeah, bubble sort is a requirement, else I'd use something more efficient.

    It's a 2D array, in that is starts off as an X by Y array of random variables (The row and column variables are passed in as a and b, respectively.) I'm trying to get it to sort in increasing order.

    Anyways, here's what I'm trying to get it to do:

    While (cycling through the array)
    If (Array[x][y] > Array(Next variable,...
    See more | Go to post

    Leave a comment:


  • Acolyte
    started a topic 2-dimensional array bubble sort
    in C

    2-dimensional array bubble sort

    Hey, I'm working on a project that involves sorting a two-dimensional array of integers using bubble sort. I've got it semi-working, my only issue is that it seems to be 'losing' values, I'm assuming when it gets to the end of a line in the array. It also has to run several times to get the values it keeps in completely correct order.
    Here's what I've got so far:
    Code:
    int SortArray (int Array[][N], int a, int b)
    {
    ...
    See more | Go to post

  • Acolyte
    started a topic Help with Pancake Sorting
    in C

    Help with Pancake Sorting

    Alright, I'm working on a pancake sorting program, and I'm currently working it to try and switch the position of the first and the largest numbers, then invert the array. Anyways, here's what I have ATM:
    Code:
    #include <stdio.h>
    void main (void)
    
    {
            int array[5], temparray[5], f, g, l, flip, lgp, lgn = 0;
            printf("Please enter the numbers: ");
            for (f = 0; f < 5;
    ...
    See more | Go to post

  • Acolyte
    replied to Flipping a section of an array
    in C
    Alright, I've made the modifications, and got parts of the array to flip. Now, the next part.
    By the way, I'm supposed to be working towards creating a Pancake Sorting program, so if anybody has any help at all for that, I'd love to see it.

    Anyways, here's my next hurdle-I'm trying to get it to find the largest number, have it switch places with the first number, then invert the whole array. As usual, here's what I have:...
    See more | Go to post

    Leave a comment:


  • Acolyte
    replied to Flipping a section of an array
    in C
    Alright, here's what I've got so far for it:
    Code:
    #include <stdio.h>
    void main (void)
    
    {
            int array[5], temparray[5], f, l, flip;
            printf("Please enter the numbers: ");
            for (f = 0; f < 5; f ++)
    
            {
                    scanf("%d", &array[f]);
                    temparray[f] = array[f];
            }
    ...
    See more | Go to post

    Leave a comment:


  • Acolyte
    started a topic Flipping a section of an array
    in C

    Flipping a section of an array

    Hey, another question. How do you flip a section of a one-dimensional array? For example, you have array[5] = {1,2,3,4,5}, and I want to flip the last 3 numbers, to produce array[5] = {1,2,5,4,3}.

    Any help would be much appreciated!
    See more | Go to post

  • Beautiful, thanks!

    Knew it was something small like that.
    See more | Go to post

    Leave a comment:


  • A (likely really simple) random number generator question

    Preface: Yes, I know. I'm a noob. I'm currently in an Intro to Programming class at university. So, I'm betting everybody here can answer this question, and I'm gonna feel silly for not knowing the obvious answer. But, hey, whatever gets my assignments done.

    Anyways. Here's part of an assignment I'm working on:
    Code:
    #include <stdio.h>
    #include <time.h>
    
    int rand(void);
    void srand(unsigned
    ...
    See more | Go to post
No activity results to display
Show More
Working...