char in[100], *temp[10],var[10][10];
int i, n = 0,
double val[10];
var[0][]="ANS";
I want to assign a string to var[0][0,1,2] which is 'ANS', but does not work and i cannot figure where i am wrong about ... |
Hey everyone, I'm basically new to programming. I've decided to try and get started with C (not C++ or C#) and so far I've been doing pretty well. I managed to ... |
I need to hold an array of C strings. Now I know C strings are just an array of chars so essentially what I want is a 2d array of chars. ... |
May I know how I can a write a character string into a 2D character array?
I need to read every character in the string and put it into a 2D ... |
I have an interesting problem.
I define,
typedef char *string;
char array[10];
string buf[10];
i=0;
while(1){
array=<assign_string>
...
|
I'm declaring an array of strings very simply, hard-coded, but it keeps giving me the array type has incomplete element type error.
I guess this has something to do with the length ... |
alright so the goal is to open a file scan in the lines and have the user edit various aspects of each section starting with lines similar to: Ball David Tucson 52000 Doe Oscar Tucson Phoenix 12225.89 Miller Janet SanDiego 120000 in which a lastname, firstname, and city character array will be declared and utilized, along with a int digit array. ... |
|
[SIZE="2"][COLOR="Black"]let me guys, look at my program, i can register upto 3 members and can view it... but i dont know how to clear the string in 2dimensional array i declared the variables (ex. name[3][20]) 3 for the number of array.... 20 for the length of the string... who can do delete code for the array? here's my program.... Code: #include ... |
#include #include #include int main (void){ char *ptr; char *add; int length; char *temp; char i; ptr = (char *) malloc (sizeof(char) * 10); for (i = 0; i < 10; i++){ length = strlen("testing"); add = (char *) malloc (sizeof(char) * length); strcpy(add, "testing"); temp = ptr + i; temp = add; } for (i = 0; ... |
You're getting confused by when an array is an array, and when it decays into a pointer to the first element of the array. Perhaps some examples for illustration Code: #include #include #if 0 arr1 +---+---+---+---+---+---+---+---+---+---+---+---+ | h | i | . | . | . | . | a | l | l | . | . | ... |
|
Hi , I have this program where in i first add list of names to a 2d array of strings and then i ask the user to enter his name. If his name is there he is welcomed else he is told to get out. But the comparison of the userinput is not happening with the stored names is the array. ... |
#include int main() { int coords[8][2]; char data[] = "(0,2)(1,3)(2,4)(3,5)(4,6)(5,7)(6,8)(7,9)"; char * scan = data; int i = 0; while ( *scan != '\0' ) { int pos; if ( 2 == sscanf( scan, "(%d,%d)%n", &coords[i][0], &coords[i][1], &pos ) ) { scan += pos; i++; } else { break; } } i = 0; while (i < 8) { printf( ... |
|
|
Allright, my assignment was to read in user data in the form name,age,sport. I then had to reverse the letters in the name, and then print all of the inputted data out last-first in the order sport age reversedname. For some reason my code to reverse the name string isn't doing anything. I used a multidimensional string array for each object ... |
|
A "small" example would probably end up being the complete function, so here's some pointers instead: Your function prototype might look like this: >>insert (char *s, int InsertOffSet, char c) and you'd call it like so: >>insert (check[0], 4, 'd'); Now within the function, you need to store away the existing character at offset 4 into a temp variable, then you ... |
Someone posted a question as to how a program could be written to ask questions, obtain an answer, and then compare it the user answer to the correct answer. I replied with a method of hard coding the questions and answers into an array, but thought about it in more detail. It might be useful to have an instructor be able ... |
C is kind of a lower-level high-level language. That requires us to understand a bit more of what's happening just below the surface in C than in many other high-level languages that include features that do a lot for you while they hide the details from you. In C, you need to be aware of what your code is doing. Especially ... |
hello all, I will try to explain as good as possible.. I have a character array, lets say: [a b c d e] [f g h i j] [k l m n o] and I have three strings, str1[5], str2[5], str3[5]. how can I make these strings get the following values in them?: str1[]=abcde str2[]=fghij str3[]=klmno Thanks a lot Pete |
#include #include int main() { //You're intializing a two dimensional array with a one-dimensional initializer. //This may cause problems. char a[4][4]={'j','u','s','t'}; int i,l,j,k,b=4,n; //If b is the number of characters, why not name it numchars or something like that? //Asking the user to enter a string and not giving him a chance to input. printf("Enter the string"); printf("\n"); //What's the point ... |
|
#include "tools.c" void Add_Movie(string movies [][]); void Delete_Movie(string movies[][]); void Modify_Movie(); void List_Movie(string movies[][]); void Add_Customer(); void Delete_Customer(); void Modify_Cusyomer(); void List_Customer(); void Exit(); main(){ string movies[100][6]={{"212","Titanic","1997","Drama","yes"}, {"114","The Godfather","1972","mafia","yes"}, {"439","The Matrix","1998","SciFi","no"}, {"821","Avatar","2009","SciFi","yes"}}; /*banner();*/ int n; printf("\t\t **** Main menu ****\n\n"); printf("\t1.Add Movie.\t5.Add Customer.\n\t2.Delete Movie.\t6.Delete Customer.\n"); printf("\t3.Modify Movie.\t7.Modify Customer.\n\t4.List Movie.\t8.List Customer.\n"); printf("\n\n \t\t\t\t0.Exit \n"); scanf("%i",&n); switch(n){ case 0:printf("\n Good Bye\n"); break; case ... |
I am developing one project in C language,In it several records are there... By maintaing those kind of records,I easily store the record name {For eg. filename 1 filename2 means i know how to store it by using 2 Dim. array but i dont know how to print it or read it in a output}.If it okay means send the reply ... |
|