Thanks, laserlight, I followed C_ntua's
advice to dive into C++ and it's fun.
Type: Posts; User: hilarius
Thanks, laserlight, I followed C_ntua's
advice to dive into C++ and it's fun.
I have a question about this class:
class Word {
public:
Word();
...
private:
string lemma;
Thank you very much for your opinions! I'll stick with C. and if I'm stuck, I know a good place to ask for some help. ;)
I'm sorry, I don't want to start a flame war, but I'm trying to figure out if C is actually suited for my (hobby)-project, which has to do with the syntax of a natural language. It has to look up...
Well, maybe it's a stupid question, but I don't know the answer and I hope to see one here.
What happens if i enter a letter instead of an integer number? The program doesn't complain, it just takes the wrong integer.
#include <stdlib.h>
#include <stdio.h>
int main(){
int a;...
I read that the scanf function is not safe. I made an attempt for a getInt(), but I'm not happy about it. I have to give two arguments: the max value and the max length of the number (I mean the max...
Anyone who read this book? If so, did you like it?
Look again at this for-loop:
for(int j=0; j<0; j--){
How many times will the loop be executed?
Think about how you could rewrite this to make it work.
That's true: it should be:
char p[] = {'a', 'b', 'c', 'd', 'e', '\0'};
Sorry for the inconvenience, but I adapted the original post.
char *p = "abcde";
char p[] = "abcde";
In the first statement the address of the first element of the string literal "abcde" is assigned to p. This string literal is constant.
The second...
Which skills you don't have? Opening a file? Reading a line? ....?
And last but not least: end the main() with a
return 0;
You're welcome !
the problem is in this line:
line[count] = temp;
You are assigning a string to a char array. You can't do this with the =-operator.
You should # include <string.h> and use strcpy() to...
That's what I asked you to do. Now try to find out how to implement strcomp with pointers.
Laserlight, you are right:
#include <stdio.h>
int main(void)
{
char a[6] = "hello";
char * p = a;
There is a pointer passed: in my post above I said that array names are equivalent with pointers. If you take str, it is seen as the address of the first element of the array.
Should I have said: "An array name is an address?" Is this correct? In any case you can do pointer arithmetics with an array name (like *(a+1) in my example). This let me make the conclusion that an...
Another important fact to know is that if
char a[6] = "hello";
int i = 0;
then these two statements are the same: a[i] and *(a + i)
A hint, but you should try to implement it yourself:
int strcomp(char *, char *);
or even better:
int strcomp(const char *, const char * );
You didn't 'make' any pointer but you're using a function that takes a pointer as an argument:
size_t strlen ( const char * str );
str is a pointer to char.
Aww... this thread is becoming like my nickname....;)
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(){
int i;
int j;
int k;
for(i = 0; i < 30000; i++)
Hello, it's better to post this question in the C # subforum.