Haha thanks!
Type: Posts; User: eurus
Haha thanks!
using this code:
char **maze;
maze = (char **) malloc(20 * sizeof(char *));
if(maze == NULL)
{
printf("ERROR cannot be allocated");
Nope switching it isnt the problem, products output like so.
11111111111111111111
11111111111111111111
11111111111111111111
11111111111111111111
11111111111111111111
11111111111111111111...
Here is my input for this code.
1
11111111111111111111
11111111111111111111
1111S000G11111111111
11111111111111111111
11111111111111111111
11111111111111111111
11111111111111111111
thanks a bunch
Example:
struct stackNode **xstack;
push(xstack, 5);
push(xstack, 5);
printf("%d %d", pop(xstack), pop(xstack));
Im getting crashes if I initialize more than one stack using this code.
struct stackNode{
int data;
struct stackNode *nextptr;
};
Hello, I have a task of solving a 20 by 20 maze. The problem im facing is that currently, I take a .txt file in and have to solve a maze for J amount of mazes.
Im having problems getting my if...
so should do something like
if(fscanf("%d", &array[i][j])
else(fscanf("%c", &array[i][j])
Ok gotcha, so if I didn't know when the character was going to be coming in how would I cast it to take the acsii code for the two letters while still taking in the integers?
I have a two dimensional array that will be taking in about 38 numbers and 2 letters randomly.
I allocate the memory for 20 columns and 20 lines and take in simple 1 digit numbers and two...
Ah yes, create some sort of a flag inside the loop to exit out or modify your while statement.
I know bubble sort has O(n^2) and that is really bad, anyone have an extremely fast way of going about this? (sorting LOTS of strings)
My question is:
What is the best algorithm for alphabetizing strings of chars in C?
try putting else in brackets?
else
{
printf("How many individual units of food do you wish to buy: ");
scanf("%d", &amount);
No compile errors or anything but wondering if thats bad style/practice.
Alright, I understand that
now does that apply for needing 2 elements per line
am I not allocating enough to have 2 elements(each with 30 chars) on x number lines?
should I
with the [0][0] though I get an error, only works with
scanf("%s %s", c2names[0]);
and that was a typo for the post should be
scanf("%s %s", c2names[0][0], c2names[0][1]);
ok
input via file
**
2 2
Hi there
my name
**
2 and 2 is the numbers that signify 2 rows. 2 columns
Well heres what is going on in my head,
I want to take in say 10 lines and 2 words per line (seperate)
so
char **c2names;
c2names = (char **) malloc(amount_of_lines * sizeof(char *));
yes but what if I want to take in 2 words
correct way to call it would be
scanf("%s %s", c2names[0][0], c2names[0][0]);
?
Here is what I basically need:
I need to be able to take in say 2 words on 10 lines
each word can be a maximum of 30 chars
heres what I have but it seems incorrect:
char **c2names;...