try null terminating the different versions of array before you try to print them to the screen. I don't believe the compiler will automatically to that for you if you explicitly initalize elements of the array.

try null terminating the different versions of array before you try to print them to the screen. I don't believe the compiler will automatically to that for you if you explicitly initalize elements of the array.

Well I'm a bit of a noob but I assume you mean '\0'?
The code above does work, but not for all cases and is laborious. I was hoping to be able to do something more like this:

x = 0
for i = 0 to 5
for j = 0 to 30 by 6
array[x] = r[i + j)
x = x+ 1
next j
next i

Look for the pattern in the other assignments.

I'm afraid I have no idea what you are suggesting, I tried messing with your pseudo-code but I get it to work. One of the main problems I am having is defining something as being a multiple of 6 and also specifying a group of characters in an array. If anyone can nod me in the right direction I would be very grateful.

If it's completely not what you meant, I'm sorry, a little new to this

No, it's not quite.

First, please learn to format your code. If the code is difficult to follow, it's difficult to help. I like the way you format each line, but the indentation is extremely important throughout the program. Be consistent.

Second, in the statement for (i = 0; i < 5; i) , what is the last useless i for? That should be i++. Yes, I see it at the bottom of the loop, but that's not where it goes. All you have is a while loop using for Third, my code said for j = 0 to 30 [B]by 6[/B] . You do that by adding 6 to j: for (j = 0; j < 30; j[B]+=6[/B]) Last, x += 1; is better written as x++; -- but you probably know that.

Thanks, but I can already imitate the code you posted. What I am trying to do is make an x*6 char array from a string(it will always be divisible by 6). And then I want to be able to output the new string by reading in columns(top to bottom), not rows.

The first code I posted gives me the output I want but only for strings up to 36 characters and is very laborious.

First, please learn to format your code. If the code is difficult to follow, it's difficult to help. I like the way you format each line, but the indentation is extremely important throughout the program. Be consistent.

Second, in the statement for (i = 0; i < 5; i) , what is the last useless i for? That should be i++. Yes, I see it at the bottom of the loop, but that's not where it goes. All you have is a while loop using for Third, my code said for j = 0 to 30 [B]by 6[/B] . You do that by adding 6 to j: for (j = 0; j < 30; j[B]+=6[/B]) Last, x += 1; is better written as x++; -- but you probably know that.

So I took your advice(I assumed the j++ was not neccessary now that I have j+=6 ) and this is what I came up with, but it produced the same error:

Yes, format your code! If it's not formatted next time, you're on your own. I already gave you a link to look at.

If your definition is char a[s][6]; and you changed the assignment to a[x][6] = r[i + j]; , I would expect it to blow up. You are writing beyond the limits of the array. The second index can only go from 0 to 5. 6 is beyond the range.

1) Determine what x is.
2) Create a two dimensional array of size x by 6 using dynamic memory. I don't believe this syntax: char a[s][6]; is valid, yet.
3) Read input string into the array one char at a time using a nested loop to control access to the array elements (outer loop controls row, inner loop controls column)
4) Create a new string by adding individual letters from the above array to the end of the new string using a nested loop to control access to the array elements. (outer loop controls column, inner loop controls row)
5) Display new string (be sure to null terminate new string, if needed).

@Lerner
I don't think I'm at the stage yet where I can just take your instructions and roll with them, just not good enough yet.
Why isn't char a[s][6] valid? I'm simply defining the size of the array.
Though I will try, and i appreciate it.

@WaltP

I think I've followed the formatting rules fully and here's the code I have.

I don't understand what x is, unless it's a count for the columns, and every time x increments, we're moving to the next column.

With the array size, does char[s][6] specify 6 wide, or 7 wide? Does this mean to make the array 6 characters wide I should change the 6 to a 5?
Because I know that it starts at 0, but I assumed that for size it's different and

I also have continually returned outputs similar to this: 0x22fea0
And was wondering what causes it.

I think I've followed the formatting rules fully and here's the code I have.

Except for the TABs to SPACEs part... Otherwise, it looks much better.

My confusion is coming from the x variable and the array size.

I don't understand what x is, unless it's a count for the columns, and every time x increments, we're moving to the next column.

Call me dense, but if you don't understand what x is, why is it in your code? Since you wrote it, you need to know what each variable is.

With the array size, does char[s][6] specify 6 wide, or 7 wide? Does this mean to make the array 6 characters wide I should change the 6 to a 5?
Because I know that it starts at 0, but I assumed that for size it's different and

Why would it be 7? It's a 6. Reread what I posted last time, and check it with your book. Why aren't you looking this stuff up in your text?

I also have continually returned outputs similar to this: 0x22fea0
And was wondering what causes it.

s is an int variable. It needs to be a const int variable. See this example in WaltP's post:

int v[20];

20 is a const int, or an int literal maybe, but it amounts to the same thing. s is not, though. I have read that the next version of the standards may allow for non const ints to be used when declaring arrays in C++, though I have no first hand knowledge of that impending change. As it stands now, if you don't know the size of the array at the time of compilation, then you need to use dynamic memory rather than static memory to declare the array. Dynamic memory uses the keywords new[] and delete[]. If you haven't run into using dynamic yet, and you need to be able to use an array of unknown size in your program, then I encourage you to look up dynamic memory in your favorite reference (textbook, class handout, Google, whatever).

For simplicity sake, let's say your string is

char word[7] = "editor";

and you want to break it up into 3 pieces of two char each. To load the string into the 3 by 2 array you could do something like this:

I though it might be 7 because in arrays the counting is: 0,1,2,3,4,5,6,; making 6 the 7th integer. That's why I had 5 in before, it's the 6th integer. Also, I don't have a text, I'm not in some sort of class. I do this as a challenge.

I don't really understand what you mean by I never intialized any variables.

That shows you exactly what I mean. If you don't set the initial value of a variable -- ANY variable -- to a value, you have no idea what the value is. Saying int x; does not make x a 0. It could be anything.

So when you use a value, unless you initialize it in some manner ( x = 3; for example) your data is unknown. Print it, you get junk. Use it ( b = x*3; ) and you get junk.

I've Just finished a program and it's taking various errors. Can you show me Where its wrong?
[CODE]/********************************************************************
* Autor: Antônio Airton Cabral Neto * …

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...